在vagrant rbenv NoMethodError loaded_recipe上安装ruby 1.9.3?

前端之家收集整理的这篇文章主要介绍了在vagrant rbenv NoMethodError loaded_recipe上安装ruby 1.9.3?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试流浪汉安装,并希望将1.9.3-p327作为默认的 ruby版本.我正在使用Chef-solo和librarian-chef来管理流浪汉机器.

我为chef-solo配置的流浪汉文件看起来像这样

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中指定用户详细信息.因为你安装到系统和用户(流浪者)级别.厨师正在使用流浪盒提供的ruby.这是我为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' }
          ]
        }
      }
    ]
  },

解决方法

这似乎是由于该烹饪书正在使用的(坦率的不寻常)版本控制系统.他们的主分支不稳定,但是,如果你回到最新的标记版本,错误就会消失.我使用Berkshelf而不是图书管理员 – 厨师,但语法看起来几乎相同,所以我将包括我固定的Berkshelf线:

cookbook’rbenv’,git:’git://github.com/fnichol/chef-rbenv.git’,ref:“v0.7.2”

ref:是重要的一点.这为我修复了错误

猜你在找的Ruby相关文章