capistrano部署SSHKit :: Command :: Failed:捆绑出口状态

时间:2014-05-29 10:17:37

标签: ruby-on-rails ruby capistrano

执行命令cap production deply时出错:

DEBUG [fbb1a838]    Warning, new version of rvm available '1.25.26', you are using older version '1.25.25'.
DEBUG [fbb1a838]    You can disable this warning with:    echo rvm_autoupdate_flag=0 >> ~/.rvmrc
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]    /usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:247:in `to_specs'
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]    : 
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]    Could not find bundler (>= 0) amongst [gem-wrappers-1.2.4]
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]     (
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]    Gem::LoadError
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]    )
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]        from /usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]        from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:1208:in `gem'
DEBUG [fbb1a838]    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
DEBUG [fbb1a838]        from /usr/local/bin/bundle:18
cap aborted!
SSHKit::Command::Failed: bundle exit status: 1
bundle stdout: Nothing written
bundle stderr: /usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [gem-wrappers-1.2.4] (Gem::LoadError)
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:1208:in `gem'
    from /usr/local/bin/bundle:18
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/command.rb:98:in `exit_status='
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:164:in `block (2 levels) in _execute'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:166:in `block in _execute'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:30:in `block (5 levels) in <top (required)>'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/abstract.rb:89:in `with'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:22:in `block (4 levels) in <top (required)>'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/abstract.rb:81:in `within'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:21:in `block (3 levels) in <top (required)>'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/afzal/.rvm/gems/ruby-1.9.3-p545/gems/sshkit-1.4.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Command::Failed: bundle exit status: 1
bundle stdout: Nothing written
bundle stderr: /usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [gem-wrappers-1.2.4] (Gem::LoadError)
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:1208:in `gem'
    from /usr/local/bin/bundle:18
>

这是我的production.rb

 role :app, %w{root@ip.ip.ip.ip}
 role :web, %w{root@ip.ip.ip.ip}
 role :db,  %w{root@ip.ip.ip.ip}
 set :stage, :production

 server 'ip.ip.ip.ip', user: 'root', roles: %w{web app db}

 set :ssh_options, {
    forward_agent: true,
    user: 'root',
 }

这是我的deploy.rb

 set :application, "ip.ip.ip.ip"
 role :app, "ip.ip.ip.ip"
 role :web, "ip.ip.ip.ip"
 role :db,  "ip.ip.ip.ip", :primary => true

 set :user, "deploy"
 set :deploy_to, "/var/www"
 set :deploy_via, :remote_cache
 set :use_sudo, false

 set :scm, "git"
 set :repo_url, "git://github.com/path/to.git"
 set :branch, "master"
 set :keep_releases, 5

 SSHKit.config.command_map[:rake]  = "bundle exec rake"
 SSHKit.config.command_map[:rails] = "bundle exec rails"
 set :rvm_type, :system
 set :default_shell, "/home/user/.rvm/bin/rvm-shell -l"

 set :default_environment, {
   'PATH' => "/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:$PATH",
   "RUBY_VERSION" => "ruby 1.9.3",
   "GEM_HOME" => "/usr/local/lib/ruby/gems/1.9.1/gems",
   "GEM_PATH" => "/usr/local/lib/ruby/gems/1.9.1/gems",
   "BUNDLE_PATH" => "/usr/local/lib/ruby/gems/1.9.1/gems"
 }

 set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")

 namespace :deploy do
   desc "Tell Passenger to restart the app."
   task :restart do
     on "root@ip.ip.ip.ip" do
       execute "touch #{current_path}/tmp/restart.txt"
     end
   end

   desc "Symlink shared configs and folders on each release."
   task :symlink_shared do
     on "root@ip.ip.ip.ip" do
       execute "ln -nfs #{shared_path}/config/database.yml #> {release_path}/config/database.yml"
      execute "ln -nfs #{shared_path}/assets #{release_path}/public/assets"
    end  
  end


  desc "Sync the public/assets directory."
  task :assets do
    on "root@ip.ip.ip.ip" do
      system "rsync -vr --exclude='.DS_Store' public/assets root@ip.ip.ip.ip:#{shared_path}/"
    end
  end
 end

 after :deploy, 'deploy:symlink_shared'
 after :deploy, "deploy:restart"

1 个答案:

答案 0 :(得分:0)

Depending on the repository you're pulling your Ruby installations and updates from, there could be a command to switch between available or installed Ruby versions on the server. If using Brightbox, for example (assuming you're logged in to the server):

`$ sudo apt-get install ruby-switch

$ ruby -v ruby 1.8.7 (2012-02-08 MBARI 8/0x8770 on patchlevel 358) [i486-linux], MBARI 0x8770, Ruby Enterprise Edition 2012.02

$ ruby-switch --list ruby1.8 ruby1.9.1 ruby2.0 ruby2.1 ruby2.2

$ sudo ruby-switch --set ruby1.9.1 update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in manual mode. update-alternatives: using /usr/bin/gem1.9.1 to provide /usr/bin/gem (gem) in manual mode. `