Skip to content

Instantly share code, notes, and snippets.

@rwilcox
Created August 5, 2009 23:19
Show Gist options
  • Save rwilcox/163039 to your computer and use it in GitHub Desktop.
Save rwilcox/163039 to your computer and use it in GitHub Desktop.
# RUBY-SWITCHER AND RUBYGEMS
# ==========================================
# Thanks in part to <http://blog.thinkrelevance.com/2009/7/29/ruby-switcher-working-with-multiple-ruby-versions-has-never-been-this-easy/>
# and the other part, well, HARD WORK IS HARD!!!!
# SETUP
cd
curl -O -L http://github.com/relevance/etc/raw/26ae85c2f6c7d2640a3c75d619ad7ab8fc1cc570/bash/ruby_switcher.sh
echo "source ~/ruby_switcher.sh" >> .bash_profile
source .bash_profile
# INSTALL A RUBY, let's say 1.8.7
install_ruby_187
use_ruby_187
# now install rubygems, so we can do useful things.
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar -xvzf rubygems-1.3.5.tgz
cd rubygems-1.3.5
ruby setup.rb --prefix=~/.gem/
echo "export RUBYLIB=~$MY_RUBY_HOME/lib:~/.gem/lib" >> ~/.bash_profile
echo 'export PATH=~.gem/bin/:$PATH' >> ~/.bash_profile
source ~/.bash_profile # no sure if this is needed or not
# NOW INSTALL A GEM -- it should work now
gem install lockfile # must NOT use sudo
# POSSIBLE AREAS FOR IMPROVEMENT:
# use_ruby_187 sets $GEM_HOME (to ~/.gem/ruby/1.8). One could modify the script to
# set this to something logical (for example, ~/.gem_versions/ruby-1.8.7-p174/),
# install rubygems to ~/.gem_versions/ruby-1.8.7-p174/lib,
# and set RUBYLIB to include that path on the search parameters. I'll leave that as
# an exercise for the reader.
#
# OR just realize you are most of the way towards a working virtual-env for Ruby...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment