Ruby1.9.2+Gems: Load path not populated, autoloading fails

Platform: Windows XP 32-Bit.
Preliminaries: Fresh Ruby install (Ruby 1.9.2-p0 Binary).

After running ‘gem install nokogiri’ (any other gem can be chosen) the
$LOAD_PATH remains unchanged.
Unlike Ruby 1.9.1, the $LOAD_PATH is first populated with the
gem-specific paths after a ‘require “nokogiri”’.

Since Rubygems doesn’t intercept autoloading, the following snippet
fails on Ruby 1.9.2:

autoload :Nokogiri, ‘nokogiri’
Nokogiri

autoload_fail.rb:2:in `’: no such file to load – nokogiri
(LoadError)

On Sep 12, 5:33 am, Rickard B. [email protected] wrote:

Platform: Windows XP 32-Bit.
Preliminaries: Fresh Ruby install (Ruby 1.9.2-p0 Binary).

After running ‘gem install nokogiri’ (any other gem can be chosen) the
$LOAD_PATH remains unchanged.
Unlike Ruby 1.9.1, the $LOAD_PATH is first populated with the
gem-specific paths after a ‘require “nokogiri”’.

What you;re mentioning is a bug in 1.9.1 bundled RubyGems, which has
been corrected in 1.9.2

Since Rubygems doesn’t intercept autoloading, the following snippet
fails on Ruby 1.9.2:

autoload :Nokogiri, ‘nokogiri’
Nokogiri

autoload_fail.rb:2:in `’: no such file to load – nokogiri
(LoadError)

Do not use autoload to load code from gems, or at least use “gem
‘nokogiri’” to indicate you’re going to use it.

See the list of changes and the full changelog of Ruby 1.9.2 for
details on gem_prelude changes and associated bugs.

autoload :Nokogiri, ‘nokogiri’
Nokogiri

autoload_fail.rb:2:in `’: no such file to load – nokogiri
(LoadError)

http://wiki.github.com/rdp/ruby_tutorials_core/ruby-talk-faq#gem_loading_fails_191

It would be nice if gems could do this.
Luis’ way of

gem ‘nokogiri’
autoload :Nokogiri, ‘nokogiri’

should work I think.

If you want the old behavior to still work you could use faster_rubygems
gem.
-r

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs