Skip to content
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

0.9.1 gem appears to require Nokogiri ~> 1.6.0 on Ruby 1.8.7 #198

Closed
Umofomia opened this issue Mar 5, 2015 · 9 comments · Fixed by #199
Closed

0.9.1 gem appears to require Nokogiri ~> 1.6.0 on Ruby 1.8.7 #198

Umofomia opened this issue Mar 5, 2015 · 9 comments · Fixed by #199

Comments

@Umofomia
Copy link
Contributor

Umofomia commented Mar 5, 2015

#194 loosened the runtime requirement on Nokogiri so that version ~> 1.6.0 would be accepted for Ruby 1.9 and above:

if RUBY_VERSION < '1.9'
  #1.8.7
  s.add_runtime_dependency('nokogiri', '~> 1.5.10')
else
  s.add_runtime_dependency('nokogiri', '~> 1.6.0')
end

However, this code does not appear to be working and ~> 1.6.0 is being enforced for 1.8.7 as well.

The easiest way to reproduce this issue is to create a clean project with the following Gemfile:

source "http://rubygems.org"
gem "ruby-saml", "0.9.1"

This results in the following:

Fetching gem metadata from http://rubygems.org/..........
Resolving dependencies...
Installing systemu (2.6.4) 
Installing macaddr (1.7.1) 
Installing mini_portile (0.6.2) 
Installing nokogiri (1.6.6.2) 
Gem::InstallError: nokogiri requires Ruby version >= 1.9.2.
An error occurred while installing nokogiri (1.6.6.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.6.2'` succeeds before bundling.

If you try to add a version constraint for Nokogiri in the Gemfile, you end up getting the following error instead:

Fetching gem metadata from http://rubygems.org/.........
Resolving dependencies...
Bundler could not find compatible versions for gem "nokogiri":
  In Gemfile:
    ruby-saml (0.9.1) ruby depends on
      nokogiri (~> 1.6.0) ruby

    nokogiri (1.5.11)

So it doesn't appear that Bundler is honoring the version-dependent dependency. One possible fix I can think of is to have just one dependency that is >= 1.5.10; however, I don't know whether you would consider that to be too broad.

@Umofomia
Copy link
Contributor Author

Umofomia commented Mar 5, 2015

According to this blog post, gem runtime dependencies appear to be evaluated at build-time, not install-time, which is why this does not appear to be working.

A Wikibooks entry linked from that blog post provides a possible solution for this. I can create a pull request for this if you think this is an appropriate way to resolve this issue.

@Lordnibbler
Copy link
Contributor

@Umofomia Would you be willing to submit a PR that resolves this issue? I'm OK with the wikibooks solution.

@Umofomia
Copy link
Contributor Author

Umofomia commented Mar 6, 2015

@Lordnibbler So I tried to implement the Wikibooks solution and it does not really work the way that I originally expect it to. It appears that the extension will install the version of nokogiri you specify, but it doesn't really work with Bundler at all to make sure that the version that it installs actually resolves with the dependencies in your project's Gemfile.

For instance, I could make this gem install the following dependencies:

di = Gem::DependencyInstaller.new
begin
  if RUBY_VERSION < '1.9'
    # 1.8.7
    di.install 'nokogiri', '~> 1.5.10'
  else
    di.install 'nokogiri', '~> 1.6.0'
  end
rescue => e
  exit(1)
end

...but if a project specifies in its Gemfile a conflicting version of nokogiri (e.g., version 1.5.9), Bundler will not complain when this gem is installed. You'll end up having both versions of nokogiri installed, and the project will continue to use the version that it specifies, rather than the one this gem wants to use.

For this reason, I don't think the Wikibooks solution is the one we want. How do you feel about the other solution I previously mentioned (specify just one dependency that is >= 1.5.10)?

@Lordnibbler
Copy link
Contributor

@Umofomia Thanks for looking into this issue.

I believe we've previously locked the dependency to >= 1.5.10, and this also does not behave as expected in a Ruby 1.8.7 project. As I recall, it will still attempt to install Nokogiri 1.6.x, despite it having a dependency on Ruby 1.9 or newer. Give it a shot if you could.

@Umofomia
Copy link
Contributor Author

Umofomia commented Mar 6, 2015

@Lordnibbler Yeah, it's not ideal. I've seen other gems deal with this issue by explicitly noting in their README file to specify ~> 1.5.0 in the project's Gemfile when using Ruby 1.8. Take the aws-sdk gem for instance:

If you are using a version of Ruby older than 1.9, you may encounter problems with Nokogiri. The authors dropped support for Ruby 1.8.x in Nokogiri 1.6. To use aws-sdk, you'll also have to install or specify a version of Nokogiri prior to 1.6, like this:

gem 'nokogiri', '~> 1.5.0'

https://github.com/aws/aws-sdk-ruby/blob/aws-sdk-v1/README.md

How about something similar in the README for this gem?

@Lordnibbler
Copy link
Contributor

@Umofomia I'm ok with this approach -- can you please verify that this works as expected both in 1.8.7 and newer, and submit a pull request?

@Umofomia
Copy link
Contributor Author

Umofomia commented Mar 6, 2015

@Lordnibbler I just opened pull request #199 and tested it with various Ruby versions to make sure it works. However it looks like I will need to update the Travis CI configuration to make sure the right version of Nokogiri is installed for 1.8.7 and ree.

@Umofomia
Copy link
Contributor Author

Umofomia commented Mar 6, 2015

@Lordnibbler The Travis CI build now passes so check out the pull request when you get the chance. Thanks!

@Lordnibbler
Copy link
Contributor

fixed via #199

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

Successfully merging a pull request may close this issue.

2 participants