Installing, then finding a Ruby gem

I’m having trouble getting Ruby to find a gem I installed. Here’s what I’m doing:

  1. First off, I’m on a private server, if that makes a difference.

  2. I run “gem install facebooker” and it seems to succeed, though it reports that it had to install to ~/.gem since “/usr/lib/ruby/gems/1.8” is write protected.

  3. I try running a simple ruby script that does nothing else but require “facebooker” and I get the following error:

/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- facebooker (LoadError) \tfrom /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
\tfrom test.rb:5
Premature end of script headers: test.rb

  1. If I change the script to require the full path to the installed facebooker.rb, it gets found okay, but then an error is reported trying to load json, one of its dependencies. (I don’t understand why the already installed json gem under “/usr/lib/ruby/gems/1.8” does get found in this case, but maybe this is a different issue.)

  2. Adding the following lines to .bash_profile and then ran “source ~/.bash_profile” as instructed by the wiki ( made no difference. (And anyway, .bash_profile only applies to ssh session, right?)

export GEM_HOME="$RUN/.gem/ruby/1.8"
export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8"
export PATH="$RUN/.gem/ruby/1.8/bin:$PATH"
export RUBYLIB="$RUN/lib:$RUBYLIB"

And I’m stumped. I feel like I must be missing some obvious thing. What is it?


I’m having the same problem on my private server. I’ve installed gems before to ~/.gem. I was able to install the json gem to ~/.gem but when I use

require ‘json’

in a controller I get the error:

MissingSourceFile (no such file to load – json):