2012-10-31 67 views
2
$ bundle exec cap -S branch=master production deploy --dry-run 
/Users/myname/.rvm/lib/rvm/capistrano.rb:5: RVM - Capistrano integration was extracted to a separate gem, install: `gem install rvm-capistrano` and remove the `$LOAD_PATH.unshift` line, note also the 'set :rvm_type, :user' is now the default (instead of :system). (RuntimeError) 

這就是我得到的。不知道發生了什麼事。思考?Capistrano試圖部署時抱怨

編輯deploy.rb

# RVM is used for ruby 1.9.2 - this is so cap can see the rvm gemset. 
$LOAD_PATH.unshift "lib", File.expand_path('./lib', ENV['rvm_path']) 

set :stages, %w(sandbox qa production) 
require 'capistrano/ext/multistage' 
require 'bundler/capistrano' 
require 'airbrake/capistrano' 
require 'chef/capistrano' 
require 'secure_files/capistrano' 
require "rvm/capistrano" 

set :rvm_ruby_string, '1.9.2' 
set :rvm_bin_path, '/usr/local/rvm/bin' 
set :user, "root" 
set :scm, :git 
set :repository, "[email protected]:Myact/fbadapter.git" 
set :deploy_to, '/var/www/fbadapter' 
set :deploy_via, :remote_cache 
set :rails_env, Proc.new {stage} 
set :application, 'fbadapter' 
set :default_environment, Proc.new { { 'RAILS_ENV' => stage } } 
set :rake, "bundle exec rake --trace" 
set :foreman_bin, 'bundle exec foreman' 
set :rake, "#{foreman_bin} run rake" 
set :rails, "#{foreman_bin} run rails" 
set :app_user, 'www-data' 

set :bundle_without, [:development, :test, :ops, :darwin] 

# this must be set before foreman/capistrano is read 
set :foreman_roles, [:app] 
require "foreman/capistrano" 

after 'multistage:ensure' do 
role_from_chef :db, 'app', :limit => 1, :primary => true # perform db operations on one of the app servers 
role_from_chef :web, 'app' 
role_from_chef :app 
role_from_chef :queue 
role_from_chef :cron 
end 


before 'deploy:symlink', 'deploy:assets:precompile', 'deploy:migrate' 
after 'deploy:symlink', :set_application_permissions 

after 'deploy', 'deploy:cleanup', 'campfire:deploy_stop' 
after 'rollback', 'campfire:deploy_rollback' 

desc 'Changes the permissions for the release path to be used with www-data' 
task :set_application_permissions do 
    run "chown -R #{app_user}:#{app_user} #{release_path}/*" 
end 

# These services are monitored by monit, but interacting with them that way 
# is hugging-every-cat crazy. This means we're assuming two thin procs per 
# app server; if that changes then remember to change this too. 

namespace :deploy do 
    task :stdout_logger do 
    run "cd #{release_path} && #{rails} plugin install https://github.com/ddollar/rails_log_stdout.git" 
    end 

    before 'deploy:symlink', 'deploy:stdout_logger' 
end 
+0

你可以分享你的deploy.rb嗎? – dpassage

+0

以上加到OP – Shamoon

+2

你是否按照錯誤信息中所說的去做? –

回答

2

這是我在我的。這些是我必須使用rvm-capistrano寶石的唯一線路。如果有幫助,我也會將其作爲非sudo用戶進行部署。

set :rvm_ruby_string, '<interpreter>@<gemset>' 

# Load RVM's capistrano plugin. 
require "rvm/capistrano" 
set :rvm_path, "$HOME/.rvm" 

由於您正在運行bundle exec,請確保rvm和rvm-capistrano gem位於您的Gemfile中。還要根據需要更改下面的rvm_ruby_string。

我相當肯定,你需要刪除這一行太

LOAD_PATH.unshift "lib", File.expand_path('./lib', ENV['rvm_path']) 

我也注意到您使用的是「根」用戶做了部署。相當肯定的是,除非爲root用戶安裝了rvm,否則不能運行。如果您必須使用root用戶,我會盡可能使用rvm包裝。

RVM Wrappers

祝你好運!

+0

不使用'root',只是通過使用root在後 – Shamoon

+0

中省略了我的用戶名我的意思是這一行「set:user」,root「 – engineerDave

1

您可以發佈新的deploy.rb文件?另外,確認rvm-capistrano gem確實已安裝?

另外,如果您還沒有將require "rvm/capistrano"添加到您的deploy.rb文件的頂部。這就是爲我工作的。

+0

我已經有'require「rvm/capistrano」'。這篇文章有我最新的'deploy.rb'。我如何確認'rvm-capistrano'確實安裝了? – Shamoon

+0

「gem list | grep rvm-capistrano」如果你的文章hase最新的deploy.rb,那麼你還沒有刪除LOAD_PATH行它說你需要刪除或添加需要的'require'rvm/capistrano''行添加... –