简体   繁体   English

通过capistrano(&rvm)部署时出现捆绑安装错误

[英]Bundle install error when deploying via capistrano (& rvm)

Now I must admit that I'm stumbling around in the dark a little bit as far as this deployment lark is concerned. 现在我必须承认,就这个部署百灵而言,我在黑暗中磕磕绊绊。 I'll try and explain the situation best I can; 我会尽力解释这种情况; I have set up a test deployment server and am trying to deploy my app to it with capistrano, however, I am encountering some difficulties surrounding my gems and their dependencies, as the error below shoes. 我已经设置了一个测试部署服务器,并尝试使用capistrano将我的应用程序部署到它,但是,我遇到了一些围绕我的宝石及其依赖关系的困难,因为下面的错误。

[mike-test] executing command
[mike-test] rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3' -c 'cd /home/deploy/myapp/releases/20120910081544 && bundle install --gemfile /home/deploy/myapp/releases/20120910081544/Gemfile --path /home/depoy/myapp/shared/bundle --deployment --quiet --without development test'
 ** [out :: mike-test] Some gems seem to be missing from your vendor/cache directory.
 ** [out :: mike-test] Could not find log4r-1.1.10 in any of the sources
command finished in 9134ms
*** [deploy:update_code] rolling back

log4r isn't in my gemfile so I can only assume it's a (perhaps production only?) dependency of another gem. log4r不在我的gemfile中,所以我只能假设它是另一个gem的一个(可能只生产?)依赖项。 I don't know why bundler isn't downloading the gem and installing it if it can't find it? 我不知道为什么Bundler没有下载宝石并安装它,如果它找不到它? I put the gem in my gemfile, ran bundle install locally, and then committed and deployed again and got the same error but with a different gem this time (spreadsheet), so that appeared to solve the error in that case only, but doesn't identify the problem. 我把gem放在我的gemfile中,在本地运行bundle install,然后再次提交和部署并得到相同的错误,但是这次使用了不同的gem(电子表格),所以在这种情况下似乎只解决了错误,但是没有找出问题所在。

Something else to muddy the water, I'm trying to use RVM on the production server and despite reading a lot about it I'm still not 100% sure I get how it works, so that might be a factor. 还有其他东西让水变得混乱,我正在尝试在生产服务器上使用RVM,尽管我已经阅读了很多关于它的信息,但我仍然不能100%确定它是如何工作的,所以这可能是一个因素。

My deploy.rb : 我的deploy.rb

require "bundler/capistrano"
require "rvm/capistrano"

# SCM Settings
set :rvm_ruby_string, '1.9.3' 
set :use_sudo, false

ssh_options[:forward_agent] = true
default_run_options[:pty] = true

set :branch, :mikedev
set :deploy_via, :remote_cache
set :copy_cache, true
set :git_enable_submodules, 0
set :repository, "our_git_repo.git"
set :scm, :git
set :user, :deploy
set :keep_releases, 1

set :application, "myapp"
set :deploy_to, "/home/deploy/myapp"
set :branch, "mikedev"

role :web, "mike-test"                          
role :app, "mike-test"                          
role :db,  "mike-test", :primary => true      

namespace :deploy do

  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end

  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do ; end
  end

end

Any guidance would be much appreciated. 任何指导都将非常感谢。

bundle install --deployment ... will not download any gems if vendor/cache is present. bundle install --deployment ...如果有vendor/cache则不会下载任何gem。 It'll look for gems just there. 它会在那里寻找宝石。 There are two options: 有两种选择:

  • remove vendor/cache directory (even if it's already empty) from your VCS 从VCS中删除vendor/cache目录(即使它已经是空的)
  • or run bundle package and add all new files under vendor/cache to your VCS 或运行bundle package并将vendor/cache下的所有新文件添加到VCS

The latter seems to be better option. 后者似乎是更好的选择。 In this way you protect your deployment from outages of rubygems servers. 通过这种方式,您可以保护您的部署免受rubygems服务器的中断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM