New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jaymzh opened this Issue Feb 29, 2012 · 9 comments

Comments

Projects
None yet
2 participants
@jaymzh
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

This comment has been minimized.

Show comment
Hide comment
@jaymzh

jaymzh Feb 29, 2012

Collaborator

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

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@jaymzh

jaymzh Feb 29, 2012

Collaborator

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

Collaborator

jaymzh commented Feb 29, 2012

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

@jaymzh

This comment has been minimized.

Show comment
Hide comment
@jaymzh

jaymzh Feb 29, 2012

Collaborator

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.

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@acrmp

acrmp Feb 29, 2012

Member

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.

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 added a commit that referenced this issue Feb 29, 2012

Resolve yajl-ruby activation order problem.
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 added a commit that referenced this issue Feb 29, 2012

@acrmp

This comment has been minimized.

Show comment
Hide comment
@acrmp

acrmp Feb 29, 2012

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@jaymzh

jaymzh Feb 29, 2012

Collaborator

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.

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@acrmp

acrmp Feb 29, 2012

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@jaymzh

jaymzh Feb 29, 2012

Collaborator

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.

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@acrmp

acrmp Mar 1, 2012

Member

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

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 Mar 1, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment