Part 1 of this series is here.
I originally was going to have this part come later in this series, but I wanted to install Ruby on Rails a bit before I started writing my blog application so that I could become more familiar with the programming language and the web framework. Add to that, the fact that I installed it last night makes it fresh in my head.
I picked Kubuntu to be my development platform for a few reasons. I’d really like to use a Mac along with TextMate, but I don’t have the capital for a new Mac. Oh sweet, MacBook, I will have you one day…
But I digress, it’s probably best to use Kubuntu at first anyway. One of the reasons why I chose this distribution of Linux is because, well, I wanted to learn Linux. I chose this specific distribution because I plan on using Debian as my production platform and since Kubuntu is based on Debian it seemed to make sense. I should note that I don’t use Ubuntu because it comes with the terrible GUI, GNOME (although I’m perfectly aware that I can switch to KDE using Ubuntu, I just wanted it all in one package).
Anyway, it’s time to get to the good stuff.
With modern Linux distributions, you can install software using a package manager and Kubuntu (and Debian) is no different. I could have easily downloaded Ruby with the apt program and then installed Rails on top of it but the latest version avaliable to the apt program is Ruby 1.8.3 while the latest version of Ruby is 1.8.4. I should note that Ruby 1.8.3 is not recommended for use with Rails.
So I had two choices, install an old (and incompatible) version with apt or install from source.
I decided on installing from source. First thing is first, I gotta install Firefox in order to browse the web (I don’t really like Konqueror – the web browser that comes with KDE) and download the source.
I run this command to get Firefox:
sudo apt-get install firefox
This installs Firefox 1.0.7 and displays a warning message when loading, but that’s fine for now – it’s not critical. It’s time to get Ruby and then Rails.
The Ruby on Rails site has very
simplistic instructions on how to install both Ruby and Rails. They are deceptively simple and as I’ve found with all things Linux, it’s actually much harder than adverstised.
I created a directory in /home/carlos called work where I could download packages and compile the programs. I download both Ruby 1.8.4 and Ruby gems into these folders.
You have to install Ruby first, so I run this command in the directory where I’ve download Ruby:
tar xvf ruby-1.8.4.tar.gz
This creates a directory called ruby-1.8.4. Moving into that directory, I attempt to run this command:
./configure
And it gives and error stating that “no acceptable C compile was found in $
PATH.”
I guess I have to install a C compiler so I run this command:
sudo apt-get install gcc
It does its thing and I try the ./configure command again. This time it’s another error. C compiler cannot create executables. Hrrm, it’s turning out that it’s not as easy as “download and go” after all.
After doing some Google searches, I found out that I need to install some development packages first, so I run the following commands (the second command is used for later when attempting to get RubyGems working):
sudo apt-get install libc6-dev
sudo apt-get install zlib1g-dev
BAM. That got it working. It does it’s thing and makes a make file. I go to make the…uh…make file and when typing in the command “make”, I get the error: bash: make: command not found. Unbelievable. I then run the following commands (which run without error):
sudo apt-get install make
make
sudo make install
I’m not sure why a base install of Kubuntu doesn’t have gcc, make, libc6-dev, and zlib1g-dev but I’ll leave that to smarter people to figure out.
I first have to unpack Ruby Gems. The command (to be run where I downloaded Ruby Gems) is
tar -xvf rubygems-0.8.11.tgz
That creates a rubygems-0.8.11 directory. The following commands are to be run in that directory:
sudo ruby setup.rb
gem install rails —include-dependencies
Note if you get an error here that reads: The error is no such file to load - zlib (LoadError), it means that you have to install zlib1g-dev first. Unfortunately you also have to go back and run the .configure, make, make install commands in the Ruby directory again.
In theory, Ruby and Rails should now be installed. Let’s test it out by running the commands:
rails /home/carlos/work/test
cd /home/carlos/work/test
ruby script/server
You should see WEBrick 1.3.1 startup and at this time, I’m satisfied that Ruby on Rails has successfully been installed.
All in all, it was way more complicated than it needed to be and if I wasn’t so determined to get it working I would have quit and just double-clicked the installer for Visual Studio.
NET 2005.