tags:

views:

230

answers:

1

I have Ubuntu 9.04 Ruby 1.8 Rubygems 1.3.5

In irb,

irb(main):002:0> require 'rubygems'
=> true

In a script

$ ./test.rb 
./test.rb:2:in `require': no such file to load -- rubygems (LoadError)
from ./test.rb:2

$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.5
  - RUBY VERSION: 1.8.6 (2009-08-04 patchlevel 383) [i686-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/


$ which ruby
/usr/local/bin/ruby

I think it may have something to do with my PATH, but I am not sure how or what to fix.

My $LOAD_PATH variable seems to have the path to the gem directories.

$ gem env gemdir
/usr/local/lib/ruby/gems/1.8
$ irb
irb(main):001:0> $LOAD_PATH
=> ["/usr/local/lib/ruby/site_ruby/1.8", "/usr/local/lib/ruby/site_ruby/1.8/i686-linux", "/usr/local/lib/ruby/site_ruby", "/usr/local/lib/ruby/1.8", "/usr/local/lib/ruby/1.8/i686-linux", "."]
A: 

Check the $LOAD_PATH, this variable contains the paths where ruby looks for when you use require.

Leventix
What I do echo $LOAD_PATH I don't see anything. How is this variable set?
Maulin
Try setting the RUBYLIB environment variable.
Leventix
My $LOAD_PATH variable seems to be set correctly (See edited question above).
Maulin