chef-dk icon indicating copy to clipboard operation
chef-dk copied to clipboard

Compass config.rb causing issues

Open smallhadroncollider opened this issue 8 years ago • 3 comments

When using ChefDK with Vagrant, if I have a Compass config.rb file in my project directory, Berks tries to read it and fails:

The following berks command failed to execute:

    /usr/local/bin/berks --version --format json

The stdout and stderr are shown below:

    stdout:
    stderr: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/webagent-cookie.rb:458: warning: already initialized constant HTTPClient::CookieManager
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/cookie.rb:8: warning: previous definition of CookieManager was here
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-config-12.7.2/lib/chef-config/workstation_config_loader.rb:159:in `rescue in read_config': You have an error in your config file /Volumes/Projects/ripetungi/saint-cooks/site/config.rb (ChefConfig::ConfigurationError)

LoadError: cannot load such file -- zen-grids
  /Volumes/Projects/ripetungi/saint-cooks/site/config.rb:13:in `from_string'
Relevant file content:
 12:
 13: require 'zen-grids'
 14:
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-config-12.7.2/lib/chef-config/workstation_config_loader.rb:138:in `read_config'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-config-12.7.2/lib/chef-config/workstation_config_loader.rb:73:in `load'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.4.2/lib/ridley/chef/config.rb:13:in `initialize'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf.rb:90:in `new'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf.rb:90:in `chef_config'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf/config.rb:80:in `<class:Config>'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf/config.rb:4:in `<module:Berkshelf>'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf/config.rb:3:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf/cookbook_generator.rb:3:in `require_relative'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf/cookbook_generator.rb:3:in `<class:CookbookGenerator>'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf/cookbook_generator.rb:2:in `<module:Berkshelf>'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf/cookbook_generator.rb:1:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf.rb:197:in `require_relative'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf.rb:197:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/lib/berkshelf/cli.rb:1:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.2.0/bin/berks:3:in `<top (required)>'
        from /usr/local/bin/berks:48:in `load'
        from /usr/local/bin/berks:48:in `<main>'


It appears that you are not using the ChefDK. Please note that Vagrant Berkshelf
works best when used with the ChefDK, and other installation methods are not
officially supported.

Please download and install the latest version of the ChefDK from:

    https://downloads.chef.io/chef-dk

and follow the installation instructions. Do not forget to add the ChefDK to
your PATH.

The file works fine with Compass and should just be ignored by Berks.

smallhadroncollider avatar Mar 22 '16 11:03 smallhadroncollider

Berkshelf is using the chef libs to load knife.rb or config.rb, the latter being what we've been moving to slowly. I'm not sure if there is an elegant way around this if it's in the same dir in path of lookup but setting a config.json for Berks might avoid this entirely.

cheeseplus avatar Jul 12 '17 21:07 cheeseplus

It should only look for .chef/config.rb though, might be an error in one of the loader systems.

coderanger avatar Jul 12 '17 21:07 coderanger

Good to know - I'll label this as a bug in that case. I figured we just searched up directories until we found it like knife.rb of old.

cheeseplus avatar Jul 18 '17 22:07 cheeseplus