Add these two lines to your ~/.bashrc file:
# this will export the path to whatever version of ruby you are using: export GEM_HOME="$HOME/.gem/ruby/`ruby -e 'x=RUBY_VERSION;print(x=~/^1.8/ ? "1.8" : x)'`" export PATH="$PATH:$GEM_HOME/bin"
Then 'source ~/.bashrc' if needed and you can use either version of rubygems indistinguishably.
Now, you can install gems with either rubygems, you don't need sudo privileges, and your gem executables will be active. Wallah!
gem install rake
2 comments:
Had a small problem, ruby -e 'print RUBY_VERSION' returns 1.8.7 while the gems are installed under ~/.gem/ruby/1.8/
Tested on Ubuntu 10.04 after installing default ruby and rubygems packages.
These packages were installed before editing ~/.bashrc if that makes any difference?
Thanks for catching that Mike. I've updated the line to work properly with 1.8, although it is a tad wordier.
Post a Comment