我将服务器更新为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
的服务器,获取相对default environment
特征。
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
文件中唯一更改的内容。 `
答案 0 :(得分:5)
- 您需要使用
default_env
来定义SHELL变量- 醇>
Permission Denied
表示您的SSH用户无权使用SSH,RVM或Bundler
<强> Capistrano的强>
第一步是确保default_environment
正常工作。虽然我找不到direct reference (search for default_env
on this page),但我认为default_environment
已被default_env
取代
如果您使用capistrano 3.0+
,则应使用default_env
,如下所示:
set :default_env, {
'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"
}
<强>权限强>
其次,您的ssh
用户无法获得访问Ruby
/ bundler
正如您在评论中所讨论的,这可能是由于ruby
或rvm
没有安装在您的系统上,或者没有权限来访问它。
@chloe
有一个惊人的建议 - 要使用它,我会使用root
用户登录(进行测试),以确保您可以实际访问bundler
或{ {1}}数据正确
答案 1 :(得分:1)
卸载Bundler,RVM,Ruby,然后重新安装它们。它对我有用。