-
Notifications
You must be signed in to change notification settings - Fork 153
foodcritic v10 and v11 have conflicting yajl-ruby dependencies with chef #14
Comments
Ignore the second half of that. I was calling the wrong path stupidly. The first error is encountered for both the RPM and direct-gem case - but only for 0.11.0, not for 0.9.0 (I'll test 0.10.0 in a second). |
fc 0.10.0 is also affected. I'm going to revert to 0.9.0 |
Looks like a dependency got added in v10 on yajl-ruby ~> 1 which installs 1.0.0 ... but before that either yajl-ruby wasn't needed, or yajl-ruby 1.1.0 (which is bundled with chef) works fine. |
Thanks for investigating this. Mea culpa. Chef uses Ohai which depends on yajl-ruby, but does not declare a version constraint - it will always try to pull down the latest stable version. Foodcritic 0.10.0 added a dependency on an old version of yajl-ruby ('~> 1.0.0'). I used the older version because I encountered a similar problem without properly reasoning it through. Foodcritic does not actually have a runtime dependency on Chef from version 0.10.0 (other than using the lucene treetop grammar to validate search syntax if available). If I remove that dependency then we should be ok because yajl-ruby will not be activated at a different version before foodcritic tries to use it. |
As Ohai does not express a version constraint against yajl-ruby we are vulnerable to activation order issues by declaring a dependency on Chef. See issue #14 for more detail.
Hi Phil, I've just pushed foodcritic 0.11.1 which should fix this by removing the dependency on Chef. Can you test it please and let me know if this is still an issue. Thanks, Andrew. |
Well, the problem doesn't exist in 0.11.1, but it doesn't really test the change you describe since you also changed the dependency on yajl-ruby to be 1.1.0 which is the same as Chef. |
Chef doesn't care about the yajl-ruby version. If you want to explore a similar condition in a clean environment you can install yajl-ruby 1.0.0 before installing Chef and then foodcritic. |
Right, but the problem was that the version chef was loading was 1.1.0 and you were loading 1.0.0. You now both require 1.1.0, so it doesn't matter what other versions you have around... Chef comes with 1.1.0 and you depend on that version, so if you both load it, in the same process space, it'd still be OK. |
Closing and foolishly claiming to have fixed this due to the lack of any compelling evidence to the contrary. |
I don't know a whole lot about multiple versions of the same gems and their interactions, but I'm using foodcritic installed into the ruby bundled with the Chef omnibuild and I get:
$ foodcritic chef/cookbooks/cron
/opt/chef/embedded/lib/ruby/1.9.1/rubygems.rb:238:in `activate': can't activate yajl-ruby (~> 1.0.0, runtime) for ["foodcritic-0.11.0"], already activated yajl-ruby-1.1.0 for "ohai-0.6.10", "chef-0.10.8", "foodcritic-0.11.0"
That's based on RPMs I built using FPM.
If I just do a straight 'gem install':
$ /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/foodcritic-0.11.0/bin/foodcritic chef/cookbooks/cron
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/foodcritic-0.11.0/bin/foodcritic:2: undefined method `require_relative' for main:Object (NoMethodError)
The text was updated successfully, but these errors were encountered: