【问题标题】:RVM / Cap / Bundler - bundle install could not find bundlerRVM / Cap / Bundler - 捆绑安装找不到捆绑器
【发布时间】:2016-02-12 18:47:51
【问题描述】:

我正在使用 RVM 运行 Capistrano,我正在尝试将部分网络应用程序迁移到新服务器。我已经完成了 cap deploy:setup 和 cap deploy:check,一切似乎都很好。当我运行我的部署时,虽然我收到了这个错误

triggering before callbacks for `deploy:finalize_update'
* 2016-02-12 10:48:56 executing `bundle:install'
* executing "cd /u/apps/platform934/releases/20160212174856 && bundle install --gemfile /u/apps/platform934/releases/20160212174856/Gemfile --path /u/apps/platform934/shared/bundle --deployment --quiet --without development test"
 servers: ["192.168.85.144"]
[192.168.85.144] executing command
** [out :: 192.168.85.144] /home/platform934/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:315:in `to_specs': Could not find 'bundler' (>= 0) among 11 total gem(s) (Gem::LoadError)
** [out :: 192.168.85.144] Checked in 'GEM_PATH=/home/platform934/.rvm/gems/ruby-1.9.3-p545@platform934:/home/platform934/.rvm/gems/ruby-1.9.3-p545@global', execute `gem env` for more information
** [out :: 192.168.85.144] from /home/platform934/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:324:in `to_spec'
** [out :: 192.168.85.144] from /home/platform934/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:64:in `gem'
** [out :: 192.168.85.144] from /usr/local/bin/bundle:18:in `<main>'
** [out :: 192.168.85.144] from /usr/local/bin/ruby_executable_hooks1.9.1:15:in `eval'
** [out :: 192.168.85.144] from /usr/local/bin/ruby_executable_hooks1.9.1:15:in `<main>'
command finished in 168ms
*** [deploy:update_code] rolling back
* executing "rm -rf /u/apps/platform934/releases/20160212174856; true"
servers: ["192.168.85.144"]
[192.168.85.144] executing command
command finished in 142ms
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'ruby-1.9.3-p545@platform934' -c 'cd /u/apps/platform934/releases/20160212174856 && bundle install --gemfile /u/apps/platform934/releases/20160212174856/Gemfile --path /u/apps/platform934/shared/bundle --deployment --quiet --without development test'" on 192.168.85.144

这是我的 deploy.rb 文件。

set :stages,        %w(staging production)¬
¬
set :default_stage, 'production'¬
require 'capistrano/ext/multistage'¬
¬
set :application, "platform934"¬
set :repository,  "git@github.com:foo"¬
set :scm,         :git¬
set :branch,      'master'¬
ssh_options[:forward_agent] = true¬
#set :user, "root"¬
#set :use_sudo, true¬
set :deploy_via, :remote_cache¬
set :ssh_options, { :forward_agent => true}¬
#set :git_enable_submodules, 1¬
default_run_options[:pty] = true¬

# RVM Setup¬
gem 'sass-rails',    '= 3.2.6'¬
#$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.¬
require "bundler/capistrano"¬
require "rvm/capistrano"
set :rvm_ruby_string,  ENV['GEM_HOME'].gsub(/.*\//,"")¬
#set :rvm_ruby_string, '1.9.3@platform934'¬
set :rvm_type, :user¬
  before 'deploy', 'rvm:install_rvm' #install rvm on target¬
  before 'deploy', 'rvm:install_ruby' #install ruby on target¬
  before 'deploy:setup', 'rvm:install_rvm'¬
  before 'deploy:setup', 'rvm:install_ruby'¬
¬
⋅⋅⋅⋅¬
# Unicorn tasks from: http://blog.teachstreet.com/building-teachstreet/how-i-learned-to-stop-worrying-and-love-the-unicorn/¬
set :unicorn_pid, "#{shared_path}/pids/unicorn.pid"¬
namespace :unicorn do¬
desc "start unicorn"¬
task :start, :roles => :app, :except => { :no_release => true } do¬
run "cd #{current_path} && bundle exec unicorn -c #{current_path}/config/unicorn-#{rails_env}.rb -E #{rails_env} -D"¬
end¬
desc "stop unicorn"¬
task :stop, :roles => :app, :except => { :no_release => true } do¬
  run " kill `cat #{unicorn_pid}`"¬
end¬
desc "graceful stop unicorn"¬
task :graceful_stop, :roles => :app, :except => { :no_release => true } do¬
  run " kill -s QUIT `cat #{unicorn_pid}`"¬
end¬
desc "reload unicorn"¬
task :reload, :roles => :app, :except => { :no_release => true } do¬
  run " sleep 3;  kill -s USR2 `cat #{unicorn_pid}`"¬
end¬
⋅¬
after "deploy:restart", "unicorn:reload"¬
end¬
¬
namespace :rvm do¬
task :trust_rvmrc do¬
 run "rvm rvmrc trust #{release_path}"¬
end¬
after "deploy", "rvm:trust_rvmrc"¬
end¬

我对 rvm 不是很有经验,我尝试手动安装 gem,但我不知道如何将它放入该目录。我真的可以使用帮助,我觉得我错过了一些非常简单的东西,只是无法在网上任何地方找到适合我的解决方案。

【问题讨论】:

  • 你是否已经在远程服务器上安装了bundle?
  • 它在本地安装在应用程序中,但不在rvm路径中:
  • GEM_PATH=/home/platform934/.rvm/gems/ruby-1.9.3-p545@platform934:/home/platform934/.rvm/gems/ruby-1.9.3-p545@global'它不在这里,但我不知道如何在 cap 部署之前将它安装在那里。
  • 如果您登录到远程服务器并运行bundler --version,您应该将bundler gem 安装在远程服务器上而不是本地计算机上,您看到了什么?跨度>
  • 对不起,我措辞不正确。它安装在目标机器上。当我执行 -gem list 时,它会在目标机器上本地安装的 gem 下列出 bundle 和 bundler,但是当我检查 .rvm 文件 bundler 不存在时,我猜它没有看到它?

标签: ruby-on-rails ruby rvm capistrano rvm-capistrano


【解决方案1】:

安装 ruby​​ 后,RVM 不会自动安装 bundler gem。 因此,每次通过 RVM 安装新版本的 Ruby 时,都必须在之后运行 gem install bundler 命令。

另一种解决方案是在~/.rvmrc/etc/rvmrc 中编辑您的rvmrc 配置并添加rvm_autoinstall_bundler_flag=1

如果 Gemfile 可用,此行将强制 RVM 安装 bundler gem 并运行 bundle install。

希望对你有帮助:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-02
    • 1970-01-01
    相关资源
    最近更新 更多