When installing gems I forget to use sudo all the time. What I end up with is warnings and gems being paced in my home folder ~/.gems instead of where I want them. It looks like this:
1 2 3 4 5 | $ gem install <gem-name> WARNING: Installing to ~/.gem since /usr/local/ruby-1.8.6-p287/lib/ruby/gems/1.8 and /usr/local/ruby-1.8.6-p287/bin aren't both writable. WARNING: You don't have /Users/jamesmead/.gem/ruby/1.8/bin in your PATH, gem executables will not run. |
If you just don’t like using sudo, here’s a good article on that: http://dev.innovationfactory.nl/2009/10/26/never-use-sudo-gem-install-again/.
If you installed them without using sudo and now want them in the right place, first you’ll need to uninstall them. A normal uninstall will give this error:
1 2 3 | $ gem uninstall <gem-name> ERROR: While executing gem ... (Gem::InstallError) Unknown gem <gem-name> >= 0 |
You might be tempted to just delete the gems folder (~/.gems). I tried that but when it gets installed the paths are stored somewhere else… long story short it won’t be pretty. Instead you need to use the –install-dir parameter when uninstalling like this:
1 2 | $ gem uninstall <gem-name> --install-dir=~/.gem/ruby/1.8/ Successfully uninstalled <gem-name>-x.y.z |