Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 在厨师烹饪书的属性中需要一个库_Ruby_Chef Infra_Require_Cookbook - Fatal编程技术网

Ruby 在厨师烹饪书的属性中需要一个库

Ruby 在厨师烹饪书的属性中需要一个库,ruby,chef-infra,require,cookbook,Ruby,Chef Infra,Require,Cookbook,在我的厨师烹饪书的attributes/default.rb中,我有以下内容: default['dt'] = ActiveSupport::TimeZone.new('America/Chicago').local_to_utc(Time.now) 在我的recipe/default.rb中,我有 chef_gem 'active_support/time' 如果我理解正确,它的工作原理和 gem install 'active_support/time' require 'active_

在我的厨师烹饪书的
attributes/default.rb
中,我有以下内容:

default['dt'] = ActiveSupport::TimeZone.new('America/Chicago').local_to_utc(Time.now)
在我的
recipe/default.rb中,我有

chef_gem 'active_support/time'
如果我理解正确,它的工作原理和

gem install 'active_support/time'
require 'active_support/time'
但在运行食谱时,我得到了

NameError
---------
uninitialized constant Class::TZInfo

如何解决名称错误?

在评估任何配方文件之前,先评估所有属性文件。因此,当配方代码运行时,gem尚未安装。即使它已经存在,它也不会包含在属性文件中,因此在那里不可用。至于如何修复它,这是一个困难的问题。我建议您将属性设置代码从属性文件中移出并放入配方中。一般来说,我不赞成这样做,但有时这是不可避免的

你的问题是什么?没有问题。