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

**URL:** <https://www.ruby-forum.com/t/ruby1-9-2-gems-load-path-not-populated-autoloading-fails/194850>\
**Category:** Ruby\
**Created:** [September 12, 2010, 10:33am UTC](https://www.ruby-forum.com/t/ruby1-9-2-gems-load-path-not-populated-autoloading-fails/194850 "2010-09-12T10:33:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbennekom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/87869e/32.png) [@rbennekom](https://www.ruby-forum.com/u/rbennekom)\
**Post date:** [September 12, 2010, 10:33am UTC](https://www.ruby-forum.com/t/ruby1-9-2-gems-load-path-not-populated-autoloading-fails/194850/1 "2010-09-12T10:33:18Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![rbennekom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/87869e/32.png) [@rbennekom](https://www.ruby-forum.com/u/rbennekom)\
**Post date:** [September 12, 2010, 9:54pm UTC](https://www.ruby-forum.com/t/ruby1-9-2-gems-load-path-not-populated-autoloading-fails/194850/2 "2010-09-12T21:54:02Z")

</div>

On Sep 12, 5:33 am, Rickard B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![rbennekom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/87869e/32.png) [@rbennekom](https://www.ruby-forum.com/u/rbennekom)\
**Post date:** [September 14, 2010, 3:22pm UTC](https://www.ruby-forum.com/t/ruby1-9-2-gems-load-path-not-populated-autoloading-fails/194850/3 "2010-09-14T15:22:51Z")

</div>

> 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](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
