I'm trying to use a gem i just installed (via sudo gem install excelsior
) like so
require 'rubygems'
require 'excelsior'
...
This works fine in irb, but when I stick exactly the same code into an .rb file and try run it with ruby I get <internal:lib/rubygems/custom_require>:29:in require': no such file to load -- excelsior (LoadError)
I guess it has something to do with the load paths apparently being completely different in irb from ruby (I'm on a mac and don't remember exactly how I installed the version of ruby I'm using).
So how do I configure ruby to have the same loadpath as irb?
One extra piece of info: some gems work, but not all :S
You can easily check what is in your irb load path:
irb(main):001:0> $LOAD_PATH
Then you can identify missing directories and include them in ruby by calling it with -I
option (which may be used more than once):
ruby -I missing_dir_1 -I missing_dir_2 your_script.rb
Edit:
There is a possibility, though I haven't tested it yet, that by installing Excelsior gem with sudo
you've put it in a directory not accessible to ruby ran without sudo
. Try sudo ruby your_script.rb
.
To see if the two executables are different versions of ruby (as suspected by some), ask it to do
puts RUBY_VERSION
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With