rvmsudo在ubuntu上的deploy.rb中不起作用

时间:2011-11-04 00:46:48

标签: ruby-on-rails ubuntu capistrano

以下是运行上限部署的错误。问题是找不到rvmsudo。

 * executing "cd /vol/www/emclab/current && rvmsudo /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems"
    servers: ["12.34.56.78"]
    [12.34.56.78] executing command
*** [err :: 12.34.56.78] sh: rvmsudo: not found

但是,在远程服务器上手动运行相同的命令“rvmsudo /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor / gems”。但为什么同样的命令在'cap deploy'中不起作用?

感谢。

这是deploy.rb:

set :application, "myapp"
set :repository,  "git://github.com/myapp/myapp.git"
set :scm, :git
set :user, "dtt"
set :use_sudo, true
set :scm_passphrase, "phrase"
set :branch, "master"
set :deploy_to, "/vol/www/#{application}"
#set :deploy_via, :remote_cache

# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

server "12.34.56.78", :web, :app, :db, :primary => true
#role :web, "your web-server here"                          # Your HTTP server, Apache/etc
#role :app, "your app-server here"                          # This may be the same as your `Web` server
#role :db,  "your primary db-server here", :primary => true # This is where Rails migrations will run
#role :db,  "your slave db-server here"

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

after "deploy", "deploy:bundle_gems"
after "deploy:bundle_gems", "deploy:restart"
# If you are using Passenger mod_rails uncomment this:
 namespace :deploy do
   task :bundle_gems do
     run "cd #{deploy_to}/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems"
   end
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
 end

1 个答案:

答案 0 :(得分:0)

我相信Capistrano不使用登录shell,因此加载RVM的.bash_profile中的行永远不会被执行。

您使用的是什么版本的RVM?如果你正在使用< 1.5,RVM内爆并重新安装。 如果您使用的是> = 1.5,请尝试将以下内容添加到deploy.rb:

require 'bundler/capistrano'

$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :rvm_ruby_string, '1.9.2'

set :rvm_bin_path, "/usr/local/bin"

将:rvm_bin_path调整到rvm可执行文件的任何位置。