tags:

views:

57

answers:

2

I do something like sudo gem install json. Then I do irb. Then I do require 'json'. Then it says no such file to load -- json

+1  A: 

Try adding this first:

require 'rubygems'

RubyGems is a dependency manager as well as an installer.

Alex Reisner
Thank you. It worked!
Drew LeSueur
+4  A: 

You need to make sure that RubyGems itself is loaded, for requiring gems to work.

There are several ways to do this. You could require 'rubygems' explicitly in each file you want to use the gems in, but that might get to be a pain. Or you could pass -rubygems into ruby when you execute it, but again, you'd need to remember to do that each time.

The best way would probably be to set the RUBYOPT environment variable to rubygems. For instance, you may add the following line to your .profile:

export RUBYOPT=rubygems
Brian Campbell
Thanks for the detail!
Drew LeSueur