RVM / Cap / Bundler - bundle install找不到bundler

时间:2016-02-12 18:47:52

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

我正在使用RVM运行Capistrano,我正在尝试将部分Web应用程序迁移到新服务器。我已完成了帽子部署:设置和上限部署:检查,一切似乎都很好。当我运行我的部署虽然我得到这个错误

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,但我不知道如何将它放入该目录。我真的可以使用帮助,我觉得我错过了一些非常简单的东西,而且无法在网上找到适用于我的解决方案。

1 个答案:

答案 0 :(得分:3)

RVM doesn't install automatically //Write out the header var csv = new CsvWriter(textWriter); csv.WriteField("A Column Data"); csv.WriteField("B (Empty)"); csv.WriteField("C (Empty)"); csv.WriteField("D (Empty)"); csv.WriteField("E (Empty)"); csv.WriteField("F Column Data"); csv.WriteField("G Column Data"); csv.NextRecord(); //Newline foreach (var item in dataList) { csv.WriteRecord(item.PropertyA); csv.WriteRecord(string.Empty); csv.WriteRecord(string.Empty); csv.WriteRecord(string.Empty); csv.WriteRecord(string.Empty); csv.WriteRecord(item.PropertyB); csv.WriteRecord(item.PropertyC); csv.NextRecord(); } gem after installing ruby. So each time you'll install a new version of Ruby via RVM you'll have to run bundler command after.

Another solution is to edit your gem install bundler configs in rvmrc or ~/.rvmrc and add /etc/rvmrc

This line will force RVM to install bundler gem and run bundle install if Gemfile available.

Hope it helps :)