我正在尝试进行vagrant安装,并希望将1.9.3-p327
作为默认的ruby版本。我正在使用Chef-solo和librarian-chef来管理流浪汉机器。
我为chef-solo设置的vagrant文件看起来像这样
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apt"
chef.add_recipe "build-essential"
chef.add_recipe "git"
chef.add_recipe "ruby_build"
chef.add_recipe "rbenv::system"
chef.add_recipe "rbenv::vagrant"
chef.add_recipe "sqlite"
chef.add_recipe "nodejs"
chef.add_recipe "mysql"
chef.add_recipe "redisio"
chef.add_recipe "redisio::install"
chef.add_recipe "redisio::redis_gem"
chef.add_recipe "zlib"
chef.add_recipe "wkhtmltopdf"
chef.json = {
"rbenv" => {
"rubies" => [ "1.9.3-p327" ],
"global" => "1.9.3-p327",
"gems" => {
"1.9.3-p327" => [
{ "name" => "bundler" }
]
}
}
}
end
和librarian-cheff寻找的cheffile看起来像这样
site 'http://community.opscode.com/api/v1'
cookbook 'apt'
cookbook 'git'
cookbook 'build-essential'
cookbook 'rbenv',
git: 'https://github.com/fnichol/chef-rbenv.git'
cookbook 'ruby_build'
cookbook 'sqlite',
git: 'git://github.com/opscode-cookbooks/sqlite.git'
cookbook 'nodejs',
git: 'http://github.com/mdxp/nodejs-cookbook'
cookbook 'mysql',
git: 'git://github.com/opscode-cookbooks/mysql.git'
cookbook 'redisio',
git: 'git://github.com/brianbianco/redisio.git'
cookbook 'zlib',
git: 'git://github.com/opscode-cookbooks/zlib'
cookbook 'wkhtmltopdf',
git: 'git://github.com/firstbanco/chef-wkhtmltopdf.git'
从这两个我应该能够运行vagrant文件,不幸的是它看起来好像在哪里我指定ruby到chef-solo的版本是轰炸出来的。它在昨天下午工作,这让我觉得有人在当时和现在之间更新了一本食谱。所以,当我打电话给图书管理员 - 厨师安装时,它拉了它并吓坏了..
================================================================================
Error executing action `install` on resource 'rbenv_ruby[1.9.3-p327] (system)'
================================================================================
NoMethodError
-------------
undefined method `loaded_recipe?' for #<Chef::RunContext:0x7f34cf773ed0>
Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rbenv/providers/ruby.rb:88:in `ruby_build_missing?'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rbenv/providers/ruby.rb:43:in `perform_install'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rbenv/providers/ruby.rb:33:in `class_from_file'
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/rbenv/recipes/system.rb
27: else
28: rbenv_ruby rubie
29: end
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/rbenv/recipes/system.rb:28:in `from_file'
rbenv_ruby("1.9.3-p327") do
retry_delay 2
retries 0
recipe_name "system"
definition "1.9.3-p327"
action :install
cookbook_name :rbenv
end
[2013-05-31T09:55:55+00:00] ERROR: Running exception handlers
[2013-05-31T09:55:55+00:00] ERROR: Exception handlers complete
[2013-05-31T09:55:55+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-05-31T09:55:55+00:00] FATAL: NoMethodError: rbenv_ruby[1.9.3-p327] (system) (rbenv::system line 28) had an error: NoMethodError: undefined method `loaded_recipe?' for #<Chef::RunContext:0x7f34cf773ed0>
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
如果我注释掉指定ruby版本的json那么它可以工作。好像不得不指定rbenv的版本但是什么是可信版本以及我在哪里可以找到它们。
编辑:您还必须在json中指定用户详细信息。因为你安装到系统和用户(流浪者)级别。厨师正在使用流浪盒提供的红宝石。这是我更新的rbenv json的ruby版本。
chef.json = {
'rbenv' => {
'user_installs' => [
{
'user' => 'vagrant',
'rubies' => ['1.9.3-p327'],
'global' => '1.9.3-p327',
'gems' => {
'1.9.3-p327' => [
{ 'name' => 'bundler' },
{ 'name' => 'rake' }
]
}
}
]
},
答案 0 :(得分:7)
这似乎是由于这本食谱正在使用的(坦率的不寻常)版本控制系统。他们的主分支不稳定,但是,如果你回到最新的标记版本,错误就会消失。我使用Berkshelf而不是图书管理员 - 厨师,但语法看起来几乎完全相同,所以无论如何我将包括我固定的Berkshelf线:
cookbook 'rbenv', git: 'git://github.com/fnichol/chef-rbenv.git', ref: "v0.7.2"
ref:
是重要的一点。这为我修复了错误!