Reputation: 441
I want to use rbgccxml with Ubuntu Precise. This gem requires nokogiri. Thus, I installed the ruby-nokogiri (v1.5.0) Ubuntu package first. Then I tried to install rbgccxml via 'gem install' but it always tries to install nokogiri (> 1.4) also. To prevent this I used 'gem install --ignore-dependencies rbgccxml'.
$ gem which rbgccxml
/var/lib/gems/1.8/gems/rbgccxml-1.0.3/lib/rbgccxml.rb
$ gem which nokogiri
/usr/lib/ruby/vendor_ruby/nokogiri.rb
Now I get strange behavior. The following script:
require 'nokogiri'
puts 'step 1'
require 'rubygems'
puts 'step 2'
require 'rbgccxml'
puts 'step 3'
outputs:
step 1
step 2
/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find nokogiri (~> 1.4.0) amongst [rbgccxml-1.0.3] (Gem::LoadError)
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:771:in `activate_dependencies'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:760:in `each'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:760:in `activate_dependencies'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:744:in `activate'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:209:in `try_activate'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:58:in `require'
from test3.rb:8
So, why nokogiri is found by require but not by require inside rbgccxml?
Upvotes: 1
Views: 514
Reputation: 26743
rbgccxml
specifies the dependency to nokogiri
using the pessimistic version constraint as follows:
gem "nokogiri", "~>1.4.0"
This is equivalent to:
gem "nokogiri", ">= 1.4.0", "< 1.5.0"
This means that rbgccxml
requires a version of nokogiri prior to the one you have installed.
If you don’t specifically need nokogiri 1.5.0, then let rubygems resolve and install the dependencies for you.
Upvotes: 1