Skip to content
This repository has been archived by the owner on Mar 21, 2018. It is now read-only.

Observed exception when client.rb includes Ohai::Config #7

Open
xsunsmile opened this issue Feb 25, 2014 · 4 comments
Open

Observed exception when client.rb includes Ohai::Config #7

xsunsmile opened this issue Feb 25, 2014 · 4 comments

Comments

@xsunsmile
Copy link

I got an exception when using

Ridley.from_chef_config('/etc/chef/client.rb')

I have these extra lines in my /etc/chef/client.rb

Ohai::Config[:plugin_path] << "/etc/chef/ohai_plugins"
Ohai::Config[:disabled_plugins] =  []

Here is the stacktrace

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/buff-config-0.4.0/lib/buff/config/ruby.rb:30:in `rescue in initialize': uninitialized constant Buff::Config::Ruby::Evaluator::Ohai (Buff::Errors::InvalidConfig)
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/buff-config-0.4.0/lib/buff/config/ruby.rb:25:in `initialize'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/buff-config-0.4.0/lib/buff/config/ruby.rb:17:in `new'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/buff-config-0.4.0/lib/buff/config/ruby.rb:17:in `parse'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/buff-config-0.4.0/lib/buff/config/ruby.rb:113:in `from_ruby'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/buff-config-0.4.0/lib/buff/config/ruby.rb:106:in `initialize'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ridley-2.5.1/lib/ridley/chef/config.rb:83:in `initialize'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ridley-2.5.1/lib/ridley.rb:40:in `new'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ridley-2.5.1/lib/ridley.rb:40:in `from_chef_config'
@mburns
Copy link

mburns commented Jan 18, 2015

I get the same when running berks in my Chef directory, using the latest version of buff-config (1.0.1) and ruby (2.0.0p481 (2014-05-08 revision 45883).

Commenting out Ohai::Config[:plugin_path] << "/etc/chef/ohai_plugins" in my .chef/knife.rb resolves the issue.

/Library/Ruby/Gems/2.0.0/gems/buff-config-1.0.1/lib/buff/config/ruby.rb:30:in `rescue in initialize': uninitialized constant Buff::Config::Ruby::Evaluator::Ohai (Buff::Errors::InvalidConfig)
    from /Library/Ruby/Gems/2.0.0/gems/buff-config-1.0.1/lib/buff/config/ruby.rb:25:in `initialize'
    from /Library/Ruby/Gems/2.0.0/gems/buff-config-1.0.1/lib/buff/config/ruby.rb:17:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/buff-config-1.0.1/lib/buff/config/ruby.rb:17:in `parse'
    from /Library/Ruby/Gems/2.0.0/gems/buff-config-1.0.1/lib/buff/config/ruby.rb:119:in `from_ruby'
    from /Library/Ruby/Gems/2.0.0/gems/buff-config-1.0.1/lib/buff/config/ruby.rb:112:in `initialize'
    from /Library/Ruby/Gems/2.0.0/gems/ridley-4.1.2/lib/ridley/chef/config.rb:83:in `initialize'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf.rb:90:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf.rb:90:in `chef_config'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf/config.rb:80:in `<class:Config>'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf/config.rb:4:in `<module:Berkshelf>'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf/config.rb:3:in `<top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf/cookbook_generator.rb:3:in `require_relative'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf/cookbook_generator.rb:3:in `<class:CookbookGenerator>'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf/cookbook_generator.rb:2:in `<module:Berkshelf>'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf/cookbook_generator.rb:1:in `<top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf.rb:197:in `require_relative'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf.rb:197:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/lib/berkshelf/cli.rb:1:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.2.3/bin/berks:3:in `<top (required)>'
    from /usr/bin/berks:23:in `load'
    from /usr/bin/berks:23:in `<main>'

@brauliobo
Copy link

same here, nasty error

@brauliobo
Copy link

any fix/workaround?

@lamont-granquist
Copy link
Contributor

you might be able to wrap your own code with:

if defined?(Ohai::Config)
  ...
end

berks/ridley/buff-config does not have any idea what Ohai::Config is.

this is a problem with using .rb files for config and then having multiple different contexts that parse the config file.

if it was a json file this couldn't happen, but you'd lose the flexibility that you're losing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants