簡體   English   中英

Chef-client似乎無法運行bundle install

[英]Chef-client can't seem to run bundle install

我正在嘗試使用application_ruby cookbook在我正在設置的服務器上部署我的Rails應用程序。 當chef-client到達運行bundle install ,它會崩潰,說它找不到bundler。 我懷疑這可能與我在這台服務器上使用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而不會出現問題。

這里出了什么問題,我該如何解決?

你設置你的環境錯了,它應該是:

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"
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM