我正在尝试使用application_ruby cookbook在我正在设置的服务器上部署我的Rails应用程序。当厨师 - 客户端到达bundle install
的运行点时,它会崩溃,说它无法找到捆绑器。我怀疑这可能与我在这台服务器上使用RVM的事实有关,但我不知道该怎么办。
这是我的申请食谱:
database_name = "app_#{node.chef_environment}"
api_deploy_key = Chef::EncryptedDataBagItem.load('keys', 'app_repository')["deploy_key"]
application "my_app" do
path "/var/www"
owner 'ubuntu'
repository "git@github.com:my_account/app.git"
revision node.chef_environment == "production" ? "master" : "develop"
deploy_key api_deploy_key
rails do
gems [['Bundler', '1.3.4']]
database_master_role 'db_master'
database do
database database_name
username "ubuntu"
password Chef::EncryptedDataBagItem.load('passwords', 'db')["password"]
end
bundler true
precompile_assets true
end
end
这是它产生的错误:
================================================================================
Error executing action `run` on resource 'execute[bundle install --path=vendor/bundle --deployment --without development test cucumber production]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of bundle install --path=vendor/bundle --deployment --without development test cucumber production ----
STDOUT:
STDERR: /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 0) among 175 total gem(s) (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:307:in `to_spec'
from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/local/rvm/gems/ruby-1.9.3-p125@global/bin/bundle:22:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `<main>'
---- End output of bundle install --path=vendor/bundle --deployment --without development test cucumber production ----
Ran bundle install --path=vendor/bundle --deployment --without development test cucumber production returned 1
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/application_ruby/providers/rails.rb
86: execute "#{bundle_command} install --path=vendor/bundle #{bundler_deployment ? "--deployment " : ""}--without #{common_groups}" do
87: cwd new_resource.release_path
88: user new_resource.owner
89: environment new_resource.environment
90: end
91: else
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/application_ruby/providers/rails.rb:86:in `block in class_from_file'
execute("bundle install --path=vendor/bundle --deployment --without development test cucumber production") do
action "run"
retries 0
retry_delay 2
command "bundle install --path=vendor/bundle --deployment --without development test cucumber production"
backup 5
cwd "/var/www/releases/30858f319060ca556b5109aa6d0ac64afa3f8e38"
environment {"RAILS_ENV"=>"staging", "PATH"=>"/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"}
returns 0
user "ubuntu"
cookbook_name "my_app"
end
如果我将rollback_on_error
设置为false,我可以手动进入签出的代码目录,并毫无问题地运行bundle install
。
这里出了什么问题,我该如何解决?
答案 0 :(得分:3)
你设置的环境错误,应该是:
environment {
"RAILS_ENV"=>"staging",
"PATH"=>"/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games",
"GEM_PATH"=>"/usr/local/rvm/gems/ruby-1.9.3-p125:/usr/local/rvm/gems/ruby-1.9.3-p125@global",
"GEM_HOME"=>"/usr/local/rvm/gems/ruby-1.9.3-p125"
}