Corey Harris
Corey Harris

Reputation: 131

Rubygems on Debian: Gems won't load (LoadError)

I've installed the development version of Crunchbang, a linux distro based off Debian. I got Ruby and Rubygems installed, but I can't get the gems I've installed to load. Here is a command-line session:

$ ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]

$ gem env
RubyGems Environment:  
  - RUBYGEMS VERSION: 1.3.6  
  - RUBY VERSION: 1.9.1 (2010-01-10 patchlevel 378) [i486-linux]  
  - INSTALLATION DIRECTORY: /usr/lib/ruby1.9.1/gems/1.9.1  
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1  
  - EXECUTABLE DIRECTORY: /usr/bin  
  - RUBYGEMS PLATFORMS:  
    - ruby  
    - x86-linux  
  - GEM PATHS:  
     - /usr/lib/ruby1.9.1/gems/1.9.1  
     - /home/corey/.gem/ruby/1.9.1  
  - GEM CONFIGURATION:  
     - :update_sources => true  
     - :verbose => true  
     - :benchmark => false  
     - :backtrace => false  
     - :bulk_threshold => 1000  
  - REMOTE SOURCES:  
     - http://rubygems.org/  

$ echo $PATH
/home/corey/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/corey/.gem/ruby/1.9.1:/usr/lib/ruby1.9.1/gems/1.9.1  

$ gem list -d nokogiri

`*** LOCAL GEMS ***`  

nokogiri (1.4.1)  
    Authors: Aaron Patterson, Mike Dalessio  
    Rubyforge: http://rubyforge.org/projects/nokogiri  
    Homepage: http://nokogiri.org  
    Installed at: /usr/lib/ruby1.9.1/gems/1.9.1  
    Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser  

$ ruby -r rubygems -e "require 'nokogiri'"
-e:1:in `require': no such file to load -- nokogiri (LoadError)  

from -e:1:in `'

I've encountered similar problems on Ubuntu before, but they were easy to fix. I can't figure out what's wrong in this particular case, and Google didn't seem to know either. Any help would be greatly appreciated!

By the way... this is my first submission to stackoverflow. I hope this question is relevant. :)

Upvotes: 3

Views: 1550

Answers (2)

Chris Kempson
Chris Kempson

Reputation: 319

Debian does not load RubyGems by default. You can solve this by adding require 'rubygems' to your code or better still, have RubyGems loaded each time Ruby is run. I also run #! and achieved this by editing my ~/.profile adding export RUBYOPT=rubygems and finally reloading my profile with . ~/.profile.

For more information on this matter see: http://docs.rubygems.org/read/chapter/3

Upvotes: 2

gaqzi
gaqzi

Reputation: 3797

Is nokogiri in any of the directories in GEM PATHS?

I've had problems before with installing rubygems from the Debian repos and then installing in manually. Debian puts all gems in /var/ somewhere in the distribution package.

Upvotes: 0

Related Questions