2012-07-10 92 views
5

我有一個VM與流浪漢和廚師。昨晚我的電腦在VM啓動並運行時意外重新啓動。之後,當我嘗試將VM虛度時,我得到: 廚師從未成功完成!任何錯誤應該在上面的輸出中可見。請修復您的食譜,以便它們正確完成。vagrant up問題

[default] VM already created. Booting if it's not already running... 
[default] Clearing any previously set forwarded ports... 
[default] Forwarding ports... 
[default] -- 22 => 2222 (adapter 1) 
[default] Creating shared folders metadata... 
[default] Clearing any previously set network interfaces... 
[default] Preparing network interfaces based on configuration... 
[default] Running any VM customizations... 
[default] Booting VM... 
[default] Waiting for VM to boot. This can take a few minutes. 
[default] VM booted and ready for use! 
[default] Configuring and enabling network interfaces... 
[default] Mounting shared folders... 
[default] -- v-root: /vagrant 
[default] -- v-data: /vagrant 
[default] -- v-csr-2: /tmp/vagrant-chef-1/chef-solo-2/roles 
[default] -- v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks 
[default] Running provisioner: Vagrant::Provisioners::ChefSolo... 
[default] Generating chef JSON and uploading... 
[default] Running chef-solo... 
stdin: is not a tty 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: *** Chef 0.10.2 *** 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: Setting the run_list to ["role[my-site]"] from JSON 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: Run List is [role[my-site]] 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: Run List expands to [memcached, my-site, my-site::vm] 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: Starting Chef Run for lucid32 
[Tue, 10 Jul 2012 00:59:37 -0700] ERROR: Running exception handlers 
[Tue, 10 Jul 2012 00:59:37 -0700] ERROR: Exception handlers complete 
[Tue, 10 Jul 2012 00:59:37 -0700] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out 
[Tue, 10 Jul 2012 00:59:37 -0700] FATAL: NoMethodError: undefined method `[]' for nil:NilClass 
Chef never successfully completed! Any errors should be visible in the 
output above. Please fix your recipes so that they properly complete. 

後來編輯:

堆棧跟蹤轉儲到/tmp/vagrant-chef-1/chef-stacktrace.out

Generated at Tue Jul 10 00:59:37 -0700 2012 
NoMethodError: undefined method `[]' for nil:NilClass 
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/my-site/recipes/default.rb:114:in `from_file' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:69:in `instance_eval' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:69:in `method_missing' 
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/my-site/recipes/default.rb:109:in `from_file' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/cookbook_version.rb:578:in `load_recipe' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/language_include_recipe.rb:40:in `include_recipe' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/run_context.rb:72:in `load' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/run_context.rb:69:in `each' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/run_context.rb:69:in `load' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/client.rb:195:in `setup_run_context' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/client.rb:159:in `run' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/application/solo.rb:192:in `run_application' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/application/solo.rb:183:in `loop' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/application/solo.rb:183:in `run_application' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/application.rb:66:in `run' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/chef-solo:25 
/opt/ruby/bin/chef-solo:19:in `load' 
/opt/ruby/bin/chef-solo:19 

任何想法,

謝謝, Radu

+0

'/ tmp/vagrant-chef-1/chef-stacktrace.out'中的堆棧跟蹤是什麼樣的? – 2012-07-10 08:10:00

+0

將其添加爲稍後的編輯 – Radu 2012-07-10 08:21:29

+0

以前廚師是否運行完成,沒有錯誤? 在'my-site/recipes/default.rb'的第114行中,您可能正在訪問某個不存在的節點屬性。看看這行代碼,你是否認識到哪裏的對象是零,你能否做到這一點,所以它不是零? – 2012-07-10 08:51:25

回答

6

這是你廚師食譜本身的錯誤。如果您閱讀堆棧跟蹤,您可以看到錯誤實際上位於my-site食譜的默認配方的第114行。您看到的Ruby錯誤意味着您正在嘗試執行諸如a[:foo]之類的操作,其中anil。當然,您不能致電[]nil

2

我有同樣的問題。我發現虛擬機中運行的主機版本太舊了(0.10.10)。

你必須更新:

 
local$ vagrant ssh 
vagrant$ gem install chef 

,然後再試一次。

+1

作爲根/ sudo運行。作爲用戶vagrant你會得到這個錯誤:「你沒有寫入/opt/vagrant_ruby/lib/ruby/gems/1.8目錄的權限」 – Henk 2013-03-17 08:10:04

0

我收到的錯誤:

Chef never successfully completed! Any errors should be visible in the 
output above. Please fix your recipes so that they properly complete. 

Error executing action `create` on resource 'mysql_service[default]' 

我用:

local$ vagrant ssh 
vagrant$ gem install chef 

再次嘗試後,這一切都制定了完善。