Problem
root@khojguru:~# irb irb(main):001:0> require 'mechanize' LoadError: no such file to load -- mechanize from (irb):1:in `require' from (irb):1
Cause
Because the of versioned nature of the gems repository, RubyGems doesn’t store the library files directly in standard library search path. It adds the necessary gem packages to the library search path as needed at run time.This means that RubyGems must be loaded before any gem libraries are accessable.
Solution
Add thisexport RUBYOPT=rubygemsto
~/.bashrc
Reload
To reload the changes you need to fire...root@khojguru:~#source ~/.bashrc
Check it out
irb(main):003:0> require 'mechanize' => true
Thats a really handy tip! I was sick of typing "require 'rubygems'" every time I started irb. Nice!
ReplyDeleteThank you. Awesome.
ReplyDeleteWonderful, tip! Thank you
ReplyDeleteNot working for me..
ReplyDeleteAgain same error, no such file to load --mechanize
There was typo: do "source ~/.bashrc" instead of "source ~/.basrc"
DeleteYou are awesome. It fixes my annoying problem!
ReplyDelete