I have a script requiring rubygems, rio, and more, plus a module in a
non-standard directory. It works fine on my machine, but not on the
machine of a friend.
Here’s the important part of my module
require ‘session’
require ‘rubygems’
require ‘term/ansicolor’
class String
include Term::ANSIColor
end
module TestMe
def sys(command)
...
end
end # TestMe
It is stored in /home/local/ruby/testme.rb
And this is the calling script:
#!/usr/bin/ruby
puts 'LOAD_PATH:',$LOAD_PATH.join("\n")
puts 'RUBYLIB:',ENV['RUBYLIB']
puts 'RUBYOPT:',ENV['RUBYOPT']
require 'rubygems'
require 'rio'
require 'testme'
include TestMe
sys('ls')
puts rio('/etc/passwd').gets
On my machine it successfully says:
tmp>testme
LOAD_PATH:
.
/home/local/ruby
/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
.
RUBYLIB:
.:/home/local/ruby
RUBYOPT:
nil
system call: ls successful
root:x:0:0:root:/home/root:/bin/bash
tmp>
But on the friend’s machine (who stores the module in
/home/rrt/local/lib/site_ruby/1.8):
tmp>testme
LOAD_PATH:
/home/rrt/local/lib/site_ruby/1.8/i386-linux
/home/rrt/local/lib/site_ruby/1.8
/usr/local/lib/site_ruby/1.8
/usr/local/lib/site_ruby/1.8/i386-linux
/usr/local/lib/site_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i386-linux
.
RUBYLIB:
/home/rrt/local/lib/site_ruby/1.8/i386-linux:/home/rrt/local/lib/site_ruby/1.8
RUBYOPT:
nil
/usr/lib/ruby/1.8/rubygems/custom_require.rb:26:in `require': No
such file
to load – testme (LoadError)
from ./testme:8
What’s wrong? Something with the rubygems installation?