Keep Ruby Gems in Your Home Directory
« How To De-Asshole-ify Links
» Because Internet Explorer is a Failure, That’s Why
Code: gems, install, Ruby, RubyGems, shared hosting
Comments Off on Keep Ruby Gems in Your Home Directory
I like keeping my Ruby Gems in my home directory. I don’t have to type sudo in front of every gem command, it’s easier to remember the path to them when I want to read their source, and I don’t have to worry about a sysadmin on a shared host updating a gem before I test it. Here’s how to make those benefits yours:
Create or edit your .gemrc to read:
gemhome: /home/your username/.gems
- /home/your username/.gems
Next, set up your login environment. Add these lines to the end of your .bashrc, .bash_profile, or .profile (whichever file you happen to already have — if you use another shell, you should already know what file is the equivalent).
export GEM_HOME=/home/your username/.gems
export GEM_PATH=/home/your username/.gems:/usr/lib/ruby/gems1.8
Last, add the following to your .ssh/environment so that gems work properly when you’re executing commands over ssh (for example, with capistrano).
You’ll need to log out and back in to update your login environment, and then you’ll be able to run gem normally. All the files get stored in the directory ~/.gems if you want to look around.