RVM,Capistrano 3和bundle失败

 王佳怡1995 发布于 2023-01-18 10:54

我正在使用Capistrano 3:

?  webapp git:(rails) ? cap --version
Capistrano Version: 3.1.0 (Rake Version: 10.1.1)

Capfile是:

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

require 'capistrano/rails'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

而我的deploy.rb是:

set :rvm_type, :user 

set :application, "my_app"

set :scm, :git
set :repo_url,  'git@github.com:nanounanue/my_app.git'
set :scm_passphrase, ""


set :ssh_options, {:forward_agent => true}
set :default_run_options, {:pty => true}
set :stages, ["vagrant"]
set :default_stage, "vagrant"


namespace :deploy do
  task :start do ; end
  task :stop do ; end
  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      run "sudo touch #{File.join(current_path,'tmp','restart.txt')}" 
    end
  end

  after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end

正如您所看到的,我正在尝试部署到Vagrant VM.

问题是当我执行(任何)命令时Capistrano发生以下情况:

?  webapp git:(rails) ? cap vagrant deploy --trace                                                  
** Invoke vagrant (first_time)
** Execute vagrant
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke rvm:hook (first_time)
** Execute rvm:hook
** Invoke rvm:check (first_time)
** Execute rvm:check
DEBUG [501eda1d] Running ~/.rvm/bin/rvm version on 192.168.33.10
DEBUG [501eda1d] Command: ~/.rvm/bin/rvm version
DEBUG [501eda1d]    
DEBUG [501eda1d]    rvm 1.25.20 (stable) by Wayne E. Seguin , Michal Papis  [https://rvm.io/]
DEBUG [501eda1d]    
DEBUG [501eda1d] Finished in 0.446 seconds with exit status 0 (successful).
rvm 1.25.20 (stable) by Wayne E. Seguin , Michal Papis  [https://rvm.io/]
DEBUG [c7fc23f0] Running ~/.rvm/bin/rvm current on 192.168.33.10
DEBUG [c7fc23f0] Command: ~/.rvm/bin/rvm current
DEBUG [c7fc23f0]    ruby-2.0.0-p247
DEBUG [c7fc23f0] Finished in 0.185 seconds with exit status 0 (successful).
ruby-2.0.0-p247
DEBUG [3fb3aad9] Running ~/.rvm/bin/rvm default do ruby --version on 192.168.33.10
DEBUG [3fb3aad9] Command: ~/.rvm/bin/rvm default do ruby --version
DEBUG [3fb3aad9]    RVM is not a function, selecting rubies with 'rvm use ...' will not work.
DEBUG [3fb3aad9]    
DEBUG [3fb3aad9]    You need to change your terminal emulator preferences to allow login shell.
DEBUG [3fb3aad9]    Sometimes it is required to use `/bin/bash --login` as the command.
DEBUG [3fb3aad9]    Please visit https://rvm.io/integration/gnome-terminal/ for a example.
DEBUG [3fb3aad9]    
DEBUG [3fb3aad9]    ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
DEBUG [3fb3aad9]    
DEBUG [3fb3aad9] Finished in 0.309 seconds with exit status 0 (successful).
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

这种情况会持续下去,当它到达bundle install部分时:

DEBUG [184656ed] Command: cd /home/vagrant/apps/releases/20140313235436 && ~/.rvm/bin/rvm default do bundle install --binstubs /home/vagrant/apps/shared/bin --path /home/vagrant/apps/shared/bundle --without development test --deployment --quiet
DEBUG [184656ed]    RVM is not a function, selecting rubies with 'rvm use ...' will not work.
DEBUG [184656ed]    
DEBUG [184656ed]    You need to change your terminal emulator preferences to allow login shell.
DEBUG [184656ed]    Sometimes it is required to use `/bin/bash --login` as the command.
DEBUG [184656ed]    Please visit https://rvm.io/integration/gnome-terminal/ for a example.
DEBUG [184656ed]    
DEBUG [184656ed]    You are trying to install in deployment mode after changing
DEBUG [184656ed]    your Gemfile. Run `bundle install` elsewhere and add the
DEBUG [184656ed]    updated Gemfile.lock to version control.
DEBUG [184656ed]    
DEBUG [184656ed]    You have added to the Gemfile:
DEBUG [184656ed]    * crossfilter-rails
DEBUG [184656ed]    
cap aborted!
bundle stdout: Nothing written
bundle stderr: Nothing written
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `call'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:164:in `block (2 levels) in _execute'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `call'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:166:in `block in _execute'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:30:in `block (5 levels) in '
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:89:in `with'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:22:in `block (4 levels) in '
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:81:in `within'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:21:in `block (3 levels) in '
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:updated => bundler:install
The deploy has failed with an error: #
** Invoke deploy:failed (first_time)
** Execute deploy:failed

我不知道发生了什么......你有蚂蚁的想法吗?

编辑:

vagrant虚拟机中.bash_profile是:

vagrant@vagrant-ubuntu-saucy-64:~$ cat .bash_profile 

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

编辑(2014年3月25日):

在@GhostGambler的建议之后,新的Capfile是:

set :default_environment, {
  'PATH' => "/usr/local/rvm/gems/ree-1.8.7-2012.02@/bin:/usr/local/rvm/gems/ree-1.8.7-2012.02@global/bin:/usr/local/rvm/rubies/ree-1.8.7-2012.02/bin:/usr/local/rvm/bin:$PATH",
  'RUBY_VERSION' => 'ree-1.8.7-2012.02',
  'GEM_HOME'     => '/usr/local/rvm/gems/ree-1.8.7-2012.02@',
  'GEM_PATH'     => '/usr/local/rvm/gems/ree-1.8.7-2012.02@'
 #,
  #'BUNDLE_PATH'  => '/usr/local/rvm/gems/ree-1.8.7-2012.02'  # If you are using bundler.
}



# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'


require 'rvm1/capistrano3'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

我补充说 deploy.rb

...

before 'deploy', 'rvm1:install:gems' 


namespace :deploy do
... 

错误仍然出现(RVM is not a function...)但它可以安装宝石,但现在它失败了另一个错误:

DEBUG [29ba9d5d] Command: cd /home/vagrant/apps/releases/20140325223229 && /tmp/arquimedes/rvm-auto.sh . gem install --file Gemfile
DEBUG [29ba9d5d]    RVM is not a function, selecting rubies with 'rvm use ...' will not work.
DEBUG [29ba9d5d]    
DEBUG [29ba9d5d]    You need to change your terminal emulator preferences to allow login shell.
DEBUG [29ba9d5d]    Sometimes it is required to use `/bin/bash --login` as the command.
DEBUG [29ba9d5d]    Please visit https://rvm.io/integration/gnome-terminal/ for a example.

DEBUG [29ba9d5d]    


DEBUG [29ba9d5d]    Using execjs (2.0.2)
DEBUG [29ba9d5d]    Using json (1.8.1)
DEBUG [29ba9d5d]    Using uglifier (2.4.0)
...
DEBUG [29ba9d5d]    Using bootstrap-sass (3.1.1.0)
DEBUG [29ba9d5d]    
 INFO [29ba9d5d] Finished in 135.237 seconds with exit status 0 (successful).
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper 
** Execute git:check
DEBUG [6f67db51] Running /usr/bin/env git ls-remote git@github.com:opintel/webapp.git on 192.168.33.10
DEBUG [6f67db51] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/arquimedes/  
...
...
DEBUG [6f67db51] Finished in 4.179 seconds with exit status 0 (successful).
** Invoke deploy:check:directories (first_time)
** Execute deploy:check:directories
 INFO [645d5072] Running /usr/bin/env mkdir -pv /home/vagrant/apps/shared /home/vagrant/apps/releases on 192.168.33.10
DEBUG [645d5072] Command: /usr/bin/env mkdir -pv /home/vagrant/apps/shared /home/vagrant/apps/releases
 INFO [645d5072] Finished in 0.011 seconds with exit status 0 (successful).
** Invoke deploy:check:linked_dirs (first_time)
** Execute deploy:check:linked_dirs
** Invoke deploy:check:make_linked_dirs (first_time)
** Execute deploy:check:make_linked_dirs
** Invoke deploy:check:linked_files (first_time)
** Execute deploy:check:linked_files
** Invoke deploy:started (first_time)
** Execute deploy:started
** Invoke deploy:updating 
** Invoke deploy:updated (first_time)
** Execute deploy:updated
** Invoke deploy:publishing (first_time)
** Execute deploy:publishing
** Invoke deploy:symlink:release (first_time)
** Execute deploy:symlink:release
 INFO [bf5c604d] Running /usr/bin/env rm -rf /home/vagrant/apps/current on 192.168.33.10
DEBUG [bf5c604d] Command: /usr/bin/env rm -rf /home/vagrant/apps/current
 INFO [bf5c604d] Finished in 0.011 seconds with exit status 0 (successful).
 INFO [72cfae75] Running /usr/bin/env ln -s /home/vagrant/apps/releases/20140325223229 /home/vagrant/apps/current on 192.168.33.10
DEBUG [72cfae75] Command: /usr/bin/env ln -s /home/vagrant/apps/releases/20140325223229 /home/vagrant/apps/current
 INFO [72cfae75] Finished in 0.011 seconds with exit status 0 (successful).
** Invoke deploy:restart (first_time)
** Execute deploy:restart
cap aborted!
ArgumentError: wrong number of arguments (1 for 0)

GhostGambler.. 7

你听说过rvm1-capistrano3吗?

这是通过投入安装 Gemfile

gem 'rvm1-capistrano3', :require => false

(不要忘记捆绑安装)并投入使用 Capfile

require 'rvm1/capistrano3'

这一下解决了我的问题.

当你修改Capfile你应该删除(或注释掉)

require 'capistrano/rvm'

因为这个宝石不需要,可能会破坏东西.

1 个回答
  • 你听说过rvm1-capistrano3吗?

    这是通过投入安装 Gemfile

    gem 'rvm1-capistrano3', :require => false
    

    (不要忘记捆绑安装)并投入使用 Capfile

    require 'rvm1/capistrano3'
    

    这一下解决了我的问题.

    当你修改Capfile你应该删除(或注释掉)

    require 'capistrano/rvm'
    

    因为这个宝石不需要,可能会破坏东西.

    2023-01-18 10:55 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有