我将服务器升级到了ruby 2.1.1,并使用Capistrano进行部署。但是每次部署时都会出现各种错误。每次更改部署代码后,错误也在变化。以下是我目前遇到的问题:
更新/新问题
重新安装rvm和ruby之后,我现在在部署中遇到了不同的问题。以下是我当前的deploy.rb文件。
require "bundler/capistrano"
require "rvm/capistrano"
set :rvm_type, :system
set :rvm_ruby_string, "ruby-2.1.1"
require 'bundler/capistrano'
# Capistrano
set :default_environment, {
'PATH' => '/root/.rvm/gems/ruby-2.1.1/bin:/root/.rvm/gems/ruby-2.1.1@global/bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
'GEM_HOME' => "/root/.rvm/gems/ruby-2.1.1",
'GEM_PATH' => "/root/.rvm/gems/ruby-2.1.1:/root/.rvm/gems/ruby-2.1.1@global",
"MY_RUBY_HOME" => "/usr/local/rvm/rubies/ruby-2.1.1",
"BUNDLE_PATH" => "/usr/local/rvm/rubies/ruby-2.1.1/bin/bundle"
}
set :rails_env, "production"
set :branch, "master"
set :app_server, "ip"
set :db_server, "ip"
server app_server, :app, :web
role :db, db_server, :primary => true
set :keep_releases, 1
set :deploy_to, "/var/www"
set :user, :jason
set :password, "cool password here"
set :repository, "git url" # Your clone URL
set :scm, "git"
set :scm_username, "jason"
set :scm_passphrase, "password"
set :use_sudo, false
default_run_options[:pty] = true
set :ssh_options, {:forward_agent => true}
after 'deploy:restart', 'deploy:cleanup'
after 'deploy:update', 'deploy:create_symlink'
运行部署时,我遇到了这个错误:
Error: RVM was unable to use 'default'
我猜这是指
rvm_ruby_string
,我没有设置它。除此之外,我不知道为什么会出现这个错误。也许RVM无法在服务器上识别ruby?
旧问题
我将服务器更新到ruby 2.1.1。通过SSH进入服务器后,我运行gem env
并获取相关的默认环境
特征。
set :default_environment, {
'PATH' => '/root/.rvm/gems/ruby-2.1.1/bin:/root/.rvm/gems/ruby-2.1.1@global/bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
'GEM_HOME' => "/root/.rvm/gems/ruby-2.1.1",
'RUBY_VERSION' => 'ruby 2.1.1',
'GEM_PATH' => "/root/.rvm/gems/ruby-2.1.1:/root/.rvm/gems/ruby-2.1.1@global"
}
然而,当我运行
cap deploy
命令时,出现了以下情况: * executing "cd /var/www/releases/20140517014048 && bundle install --gemfile /var/www/releases/20140517014048/Gemfile --path /var/www/shared/bundle --deployment --quiet --without development test"
servers: ["ip address"]
["ip address"] executing command
** [out :: ipaddress] sh: 1: bundle: Permission denied
我认为这是我的默认环境。因为这是我在deploy.rb
文件中改变的唯一内容。
/usr/bin/which: no bundle in (...
?将您的路径设置为上面的路径,然后再次运行 which。 - Chloels: cannot access /root/.rvm/gems/ruby-2.1.1@global/bin: No such file or directory
的错误信息。 - thank_you