RVM/Cap/Bundler - 软件包安装无法找到打包程序

问题描述:

我正在运行带有RVM的Capistrano,我试图将我们的部分Web应用程序迁移到新的服务器。我已经完成了帽部署:安装和帽部署:检查,一切似乎都很好。当我运行我的部署,虽然即时得到这个错误RVM/Cap/Bundler - 软件包安装无法找到打包程序

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/[email protected]:/home/platform934/.rvm/gems/[email protected]', 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 '[email protected]' -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, "[email protected]: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, '[email protected]'¬ 
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,但我不知道如何进入该目录。我真的可以使用帮助,我觉得我错过了一件非常简单的事情,只是找不到适合我的在线任何地方的解决方案。

+0

您是否已经在远程服务器上安装了捆绑软件? –

+0

它在本地安装在应用程序中,但不在rvm路径中: –

+0

GEM_PATH=/home/platform934/.rvm/gems/[email protected]:/home/platform934/.rvm/gems/ruby-1.9 .3-p545 @ global' 它不在这里,但我不知道如何在cap部署之前如何安装它。 –

安装红宝石后,RVM不会自动安装bundler宝石。 因此,每当您通过RVM安装新版本的Ruby时,都必须在运行后执行gem install bundler命令。

另一个解决方案是编辑~/.rvmrc/etc/rvmrcrvmrc CONFIGS并添加rvm_autoinstall_bundler_flag=1

这条线将迫使RVM安装捆绑宝石和运行包安装,如果Gemfile中可用。

希望它有帮助:)