- Remove all ubuntu ruby packages.
dpkg --list | grep -i ruby
to find all the packages you have installed. Then use
sudo apt-get remove packagename
to remove those packages. We are going to build all of these by hand.
- Make sure you have the ubuntu build packages
Run the following to make sure you have packages necessary to build ruby with
sudo apt-get build-dep ruby1.8
This will install stuff like autoconf and automake if you don’t already have them.
- Setup your filesystem for stow.
Let’s first make a directory under /usr/local named stow with
sudo mkdir /usr/local/stow
We will install everything here and then use stow to create symlinks in /usr/local/bin. Also, change the directory permission for /usr/local/stow so you can install stuff there as your user. This has the added benefit of alerting you if you configure wrong or try to overwrite something. We will only need to sudo to run the stow command. Run the following to see what groups you are in
Hopefully there will be a dev or adm or something similiar. I will use the adm group. Run the following to change the group and permissions on /usr/local/stow.
sudo chgrp -R adm /usr/local/stow
chmod -R 775 /usr/local/stow
- Install stow
Download the stow package with from ftp://mirrors.kernel.org/gnu/stow/stow-1.3.3.tar.gz. Then
tar -zxf stow-1.3.3.tar.gz
to extract everything. Go into the directory and then run the following.
Then install it with make and sudo make install
I considered installing stow under the stow directory but figured it was overkill
- Install ruby1.8.6
Get the code with from ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6-p287.tar.gz. Unzip and cd into the directory. Run
make && make install
You shouldn’t need to sudo if you have the permissions correct. Run
if you want ri and rdoc, but it takes a while.
- Install ruby1.8.7
Much like the 1.8.6 version, get the code with ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.7-p72.tar.gz Unzip and cd into the directory. Run
make && make install
if you want.
- Update your path
Make sure that /usr/local/bin is on your path. Since we don’t have ruby installed anywhere else, you can put it at the end. You could put it earlier if you have other versions installed.
to see if you already have it. If not, go to your .bashrc and add it where ever PATH is exported.
- Run stow
Lets set up ruby 1.8.7. Change to the /usr/local/stow directory and run
sudo stow ruby-1.8.7-p72
All the symlinks are created for you.
- Install rubygems, gems and then stow again
should show you it is version 1.8.7. You will need to install rubygems now. Get it from http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz and then extract it into a directory. Change into that directory and run
Now rubygems is installed in the ruby directory, but you will need run stow again. Change to /usr/local/stow and run
sudo stow ruby-1.8.7-p87
Running the command
should show you have it installed. You can now install gems like mongrel, rails etc. When you finish installing gems, be sure to run stow again so it will symlink the executables.
stow -D ruby-1.8.7-p22 && stow -R ruby-1.8.6-p287
The -D removes all the symlinks. Run the following to see all the options for stow
Follow the instructions above to setup rubygems and all the gems again. Remember to rerun stow so the executable are symlinked. After you install the gems the first time, switching is simply a matter of stow -D and then stow -R. Pretty clean and easy.
so it is ugly if you want to remove the packages. With stow, all you have to do is remove the directory.
I tried to cover most commands I used. If you need more unix reference, try something like this or this. Google is your friend.