0

I understand that after Ruby 1.9.2, '.' is no longer in your path for security reasons. This seems to be a problem when using certain gems (ones not updated to 1.9 I imagine?), a problem that throws errors like

$HOME/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in 'require': cannot load such file -- rubylog (LoadError)

I've seen and fixed this problem once, by (perhaps naively) changing some requires into require_relatives: https://github.com/mathpunk/MongoDB_Koans/commit/e2f7898347d328450ec121d22f701508f389cc53

Now I'd like to use rubylog, and I'm getting the custom_require error, so I tried the same trick: https://github.com/mathpunk/rubylog/commit/995e13dccc6a197d280d0783f3fb7fe50deabd02

but this time, I'm just getting the same error. What else can I try?

ETA: All this time, I've been using sudo gem install blah to install gems, and for some reason, for rubylog it's gem install rubylog that does it. (Something to do with RVM?) So now everything works. Thank you.

tom
  • 541
  • 1
  • 5
  • 16

2 Answers2

0

Just add the library directory to your LOAD_PATH:

$LOAD_PATH.unshift(File.dirname(__FILE__))

See Understanding Ruby's load paths\

Edit: I assumed you had a rubylog directory wherever your script was running from. If your script can't find rubylog then you need to add that location to your load path:

$LOAD_PATH.unshift('/path/to/rubylog')

Are you sure you have the rubylog libraries? gem install rubylog

Community
  • 1
  • 1
Just Jake
  • 4,698
  • 4
  • 28
  • 33
  • I must not understand your/your link's solution. Adding the following to the file I'm running does not change anything: `$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rubylog'` – tom Sep 20 '12 at 23:32
0

Your code fails at require 'rubylog' - so it can't find rubylog.rb itself. So just add dir containing rubylog.rb to load path - something like $: << 'rubylog' might help.

iced
  • 1,562
  • 8
  • 10