ruby-on-rails - Capistrano 在尝试部署时提示

标签 ruby-on-rails capistrano rvm-capistrano

$ 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)

这就是我得到的。不知道发生了什么事。想法?

编辑我的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,  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="11767865517678657964733f727e7c" rel="noreferrer noopener nofollow">[email protected]</a>: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

最佳答案

这是我的。这些是我必须使用 rvm-capistrano gem 的唯一行。如果有帮助的话,我也以非 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 gems 在您的Gemfile 中。还可以根据您的需要更改下面的 rvm_ruby_string 。

我相当确定您也需要删除此行

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

我还注意到您正在使用“root”用户进行部署。相当肯定,除非为 root 用户安装 rvm,否则这不会起作用。如果您必须使用 root 用户,如果可能的话,我会使用 rvm 包装器。

RVM Wrappers

祝你好运!

关于ruby-on-rails - Capistrano 在尝试部署时提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13161000/

相关文章:

deployment - 如何自动化 Node.js 部署?

capistrano - 为什么使用 Gradle 而不是 Capistrano?

ruby-on-rails - 缺少当前文件夹 Capistrano Rails 3.2

ruby-on-rails - RVM + Capistrano 失败错误 bug?

jquery - Rails 中的服务器端数据表

ruby-on-rails - 为 ActiveRecord 关联扩展编写规范

ruby-on-rails - 在启动文件中加载环境变量

html - 固定宽度元素在 Mac 上折叠

php - Capistrano:如何为 PHP 应用程序部署 MySQL 数据库?

ruby-on-rails - 为什么 capistrano multiconfig 不工作?