Installing Ruby Gems Locally
If you’re a technically advanced Ruby user and you want to install a new “Ruby Gem”, you'll need to tell Ruby where to store them.
This is necessary because if you simply try gem install something from the command line shell, you’ll see an error message saying “You don't have write permissions into the /usr/lib/ruby/gems/1.8 directory.”
To fix this, create a local directory to hold the gem, then tell the gem installer to use that directory like this:
mkdir /home/ex/example.com/gems export GEM_HOME=/home/ex/example.com/gems gem install something
The gem will properly install in that directory.
After doing that, you need to tell your Ruby application to look in the directory you created. For Rails applications, you can usually add this line to your “environment.rb” file:
ENV['GEM_PATH'] = '/home/ex/example.com/gems:/usr/lib/ruby/gems/1.8'
Important: we no longer support new Rails installations.
For non-Rails Ruby apps, you should add that line before the first “require” the script uses.