【问题标题】:rvmsudo does not work in deploy.rb on ubunturvmsudo 在 ubuntu 上的 deploy.rb 中不起作用
【发布时间】:2011-11-04 00:46:48
【问题描述】:

以下是运行 cap deploy 的错误。问题是没有找到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

【问题讨论】:

    标签: ruby-on-rails ubuntu capistrano


    【解决方案1】:

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

    您使用的是哪个版本的 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 可执行文件所在的位置。

    【讨论】:

    • 上述答案中的块是否已添加到 deploy.rb 的 Set 部分?我还需要保持 'task :bundle_gems do' 原样吗?
    • 添加上面的代码块并执行cap deploy,这里是错误:C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' : 没有要加载的文件 -- rvm/capistrano (LoadError)
    猜你喜欢
    • 1970-01-01
    • 2018-06-08
    • 2013-12-28
    • 1970-01-01
    • 2014-06-05
    • 2012-10-09
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多