Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

foodcritic v10 and v11 have conflicting yajl-ruby dependencies with chef #14

Closed
jaymzh opened this issue Feb 29, 2012 · 9 comments
Closed
Labels

Comments

@jaymzh
Copy link
Collaborator

jaymzh commented Feb 29, 2012

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)

@jaymzh
Copy link
Collaborator Author

jaymzh commented Feb 29, 2012

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).

@jaymzh
Copy link
Collaborator Author

jaymzh commented Feb 29, 2012

fc 0.10.0 is also affected. I'm going to revert to 0.9.0

@jaymzh
Copy link
Collaborator Author

jaymzh commented Feb 29, 2012

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.

@acrmp
Copy link
Member

acrmp commented Feb 29, 2012

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.
https://github.com/opscode/ohai/blob/0.6.10/ohai.gemspec#L16

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.

acrmp pushed a commit that referenced this issue Feb 29, 2012
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.
acrmp pushed a commit that referenced this issue Feb 29, 2012
@acrmp
Copy link
Member

acrmp commented Feb 29, 2012

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.

@jaymzh
Copy link
Collaborator Author

jaymzh commented Feb 29, 2012

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.

@acrmp
Copy link
Member

acrmp commented Feb 29, 2012

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.

@jaymzh
Copy link
Collaborator Author

jaymzh commented Feb 29, 2012

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.

@acrmp
Copy link
Member

acrmp commented Mar 1, 2012

Closing and foolishly claiming to have fixed this due to the lack of any compelling evidence to the contrary.

@acrmp acrmp closed this as completed Mar 1, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants