按照 Ron Cowie 在他的书定制厨师 (O'Reilly) 中创建简单 Ohai 插件的指南,我的 Windows 10 笔记本电脑上似乎没有加载 Ohai plugins_path。
步骤如下:
- 创建 Example1.rb 插件文件。我在 C:\dev\opscode\ohai\plugins\example1.rb 中这样做了
Ohai.plugin(:Example1) do 1 provides "awesome_level" 2 collect_data do 3 awesome_level 100 4 end end
- 运行 irb 并输入以下内容:
PS C:\WINDOWS\system32> irb irb(main):001:0> require 'ohai' => true irb(main):002:0> Ohai::Config[:plugin_path] = 'C:/Dev/opscode/ohai/plugins' => "C:/Dev/opscode/ohai/plugins" irb(main):003:0> o = Ohai::System.new => #<Ohai::System:0x0000000003c339a0 @cli=nil, @plugin_path="", @config={},...
在我看来,@plugin_path 好像是空的,所以在运行 o.all_plugins 然后 o.attributes_print("awesome_level")
> Results in error: irb(main):019:0> puts
> o.attributes_print("awesome_level") Traceback (most recent call last):
> 3: from C:/opscode/chef-workstation/embedded/bin/irb.cmd:19:in `<main>'
> 2: from (irb):19
> 1: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/ohai-14.8.10/lib/ohai/system.rb:178:in
> `attributes_print' ArgumentError (I cannot find an attribute named
> awesome_level!)
它是在 Windows 上设置 plugins_path 的语法吗?我试过双引号。反斜杠。