gpt4 book ai didi

ruby - 在 vagrant rbenv NoMethodError loaded_recipe 上安装 ruby​​ 1.9.3?

转载 作者:数据小太阳 更新时间:2023-10-29 06:54:09 26 4
gpt4 key购买 nike

我正在尝试 vagrant 安装并希望将 1.9.3-p327 作为默认的 ruby​​ 版本。我正在使用 chef-solo 和 librarian-chef 来管理 vagrant 机器。

我为 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 文件,不幸的是,它看起来好像我正在为 chef-solo 指定 ruby​​ 版本的地方被炸毁了。它昨天下午还在工作,这让我认为从那时到现在有人更新了一本食谱。所以当我调用 librarian-chef install 时,它把它拉了下来,吓坏了..

================================================================================
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 中指定用户详细信息。自从您安装到系统和用户( Vagrant )级别。厨师正在使用 vagrant box 提供的 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' }
]
}
}
]
},

最佳答案

这似乎是由于这本食谱使用的(坦率地说不寻常的)版本控制系统。他们的 master 分支不稳定,但是,如果您返回到最新的标记版本,错误就会消失。我使用 Berkshelf 而不是 librarian-chef,但语法看起来几乎相同,所以无论如何我都会包括我固定的 Berkshelf 行:


食谱“rbenv”,git:“git://github.com/fnichol/chef-rbenv.git”,引用:“v0.7.2”

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

关于ruby - 在 vagrant rbenv NoMethodError loaded_recipe 上安装 ruby​​ 1.9.3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16855064/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com