卡皮斯特拉诺仍未找到宝石

时间:2013-11-22 21:21:17

标签: ruby-on-rails ruby

我一直在尝试使用capistrano配置我的部署几周,但它仍然无法正常工作。每次我部署到我的服务器时,我都会收到错误信息,说明缺少某个宝石,例如:

DEBUG [a0e618f0]    /home/ec2-user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
DEBUG [a0e618f0]    : 
DEBUG [a0e618f0]    Could not find ansi-1.4.3 in any of the sources
DEBUG [a0e618f0]     (
DEBUG [a0e618f0]    Bundler::GemNotFound
DEBUG [a0e618f0]    )

我知道如何解决这个问题,只需安装“ansi”gem,但这里有一个更大的问题:为什么捆绑器没有与capistrano一起正常工作?

当我在输出中看起来更高时,我看到:

 INFO [1ee9a88e] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/SparkMyInterest/releases/20131122204608/Gemfile --path /var/www/html/SparkMyInterest/shared/bundle --deployment --quiet --binstubs /var/www/html/SparkMyInterest/shared/bin --without development test on 54.200.196.1
DEBUG [1ee9a88e] Command: cd /var/www/html/SparkMyInterest/releases/20131122204608 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/SparkMyInterest/releases/20131122204608/Gemfile --path /var/www/html/SparkMyInterest/shared/bundle --deployment --quiet --binstubs /var/www/html/SparkMyInterest/shared/bin --without development test )
 INFO [1ee9a88e] Finished in 20.132 seconds with exit status 0 (successful).
DEBUG [7d1a9e40] Running if test ! -d /var/www/html/SparkMyInterest/releases/20131122204608; then echo "Directory does not exist '/var/www/html/SparkMyInterest/releases/20131122204608'" 1>&2; false; fi on 54.200.196.1
DEBUG [7d1a9e40] Command: if test ! -d /var/www/html/SparkMyInterest/releases/20131122204608; then echo "Directory does not exist '/var/www/html/SparkMyInterest/releases/20131122204608'" 1>&2; false; fi
DEBUG [7d1a9e40] Finished in 1.291 seconds with exit status 0 (successful).
 INFO [a0e618f0] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile on 54.200.196.1
DEBUG [a0e618f0] Command: cd /var/www/html/SparkMyInterest/releases/20131122204608 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile )
DEBUG [a0e618f0]    /home/ec2-user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
DEBUG [a0e618f0]    : 
DEBUG [a0e618f0]    Could not find ansi-1.4.3 in any of the sources
DEBUG [a0e618f0]     (
DEBUG [a0e618f0]    Bundler::GemNotFound
DEBUG [a0e618f0]    )

显然,看起来捆绑包已经运行(并且成功了!)。是什么给了什么?

这是我的上限文件:

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

在我的production.rb(我正在使用生产部署)中,我有:

set :stage, :production
set :rails_env, "production"

为什么捆绑包不工作的任何想法?和/或为什么它似乎永远不会安装所有必需的宝石?

万分感谢

1 个答案:

答案 0 :(得分:0)

我通过向capitrano提供一些额外的信息来解决rvm涉及的类似问题(需要rvm / capistrano)

set :bundle_cmd, '/path/to/project/rvm/bundle'
set :default_shell, :bash
set :rvm_type, :system
set :rvm_ruby_string, release_path

此代码位于我的特定于阶段的部署中(例如,deploy / production.rb)。我必须解决的问题是捆绑软件已安装但位置错误;可能就是你在这里所面对的。

FWIW,rvm / capsitrano还允许我指定在部署脚本中运行某些命令时使用的shell。例如,我使用随时随地更新我的crontab并需要“rvm_shell”(我的宝石专用ruby)来从capistrano发生这种情况。这条线看起来像这样:

run "cd #{release_path} && bundle exec whenever -w -s environment=production", shell: fetch(:rvm_shell)