Installing Ruby on Rails on Ubuntu

This guide is valid for the following distributions:

Ruby on Rails

While there is a nice tutorial in the Ruby on Rails wiki, it’s by no means complete. According to it, you should only type: apt-get install rails to have the newest Rails installed on Ubuntu. It installs both Ruby and Rails, but what about rubygems? Sorry, not this time. There is also another caveat. Although commands like rails test and ruby script/server are working properly, ruby/console is not. If you had the misfortune of experiencing the aforementioned behavior, then this tutorial is just for you.

Pre requirements:

nano /etc/apt/sources.list

Add the following at the end of the file (replace edgy with breezy if you are running Breezy, dapper for Dapper, etc.):

# All Ubuntu repositories
deb http://archive.ubuntu.com/ubuntu edgy main restricted universe multiverse

Update your apt sources:

apt-get update

Installation:

Install Ruby with developer’s libraries:

apt-get install ruby ri rdoc irb ri1.8 ruby1.8-dev libzlib-ruby zlib1g

Download and install Ruby Gems (no .deb package, unfortunately):

wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz
tar xfvz rubygems-0.9.2.tgz
cd rubygems-0.9.2
ruby setup.rb

Update your RubyGems (also updates the gems cache):

gem update --system

If you get Could not find rubygems-update (> 0) in the repository or a similar error, you need to delete your RubyGems cache:

$ gem env gemdir
PATH_TO_DEFAULT_GEM_REPOSITORY
$ rm PATH_TO_DEFAULT_GEM_REPOSITORY/souce_cache

and

rm $HOME/.gem/source_cache

In the next step install the OpenSSL bindings for Ruby (needed to install signed gems). They are required if you get the following error: SSL is not installed on this system, while installing signed gems like rake:

apt-get install libopenssl-ruby

And the last one:

gem install rails -y

And this is basically it. There are, however, depending on your needs, some…

Additional steps:

One of them is setting up the Rails to connect to the MySQL database in a proper way. We will be using the MySQL C bindings, which, for one, support the MySQL old style passwords (which is set as default for Ubuntu 5.04), but are also significantly faster (in the 2-3x range) than the native Ruby MySQL bindings. First, we will need to install the gcc compiler (and libc6-dev if you don’t have it already installed). Although strange it may seem, as a default it is not installed on a clean Ubuntu installation.

apt-get install gcc libc6-dev

MySQL development libraries are also required (mysql_config plus mysql/include):

apt-get install libmysqlclient14-dev

(for MySQL 5.0 you might be better of with libmysqlclient15-dev).

And now we can install C MySQL bindings:

gem install mysql

If you get "sh: make: not found" do:

apt-get install make

or if you have it already installed, add it to your path:

export PATH=/usr/bin:"${PATH}"

And, of course, in the end install Mongrel:

gem install mongrel -y

And that’s it. Rails installation is complete. Complicated? Not really :) Happy coding!

Paul Graham should run for president

Or at least should be a politician.

It’s not a surprise that every single one of Paul Graham’s essays is a great read. Some are, however, simply mindblowing. Such is the case with his newest writing entitled Inequality and Risk (not that it’s that new whatsoever, it’s just that only now I’ve been able to get a hold of some free time to read it). He usually writes about startups and risks associated with running them and this essay is no different. Although this time he also talks about macroeconomics and, well, politics. In particular, he describes the dependency between the number of startups and the level of inequality in wealth of a society. The question arises: how do you deal with inequality without ruining your country?

What is surprising is that not only he finds a way to solve this particular problem, but also proposes a very sane and thoughtful solution. The simplicity and adequacy of it just blew my mind. He is just so right.

Paul Graham for president?

The magic of Ubuntu

Ubuntu Linux

After three years (has it been that long?) the time has finally come to replace my very much beloved RedHat 8.0 with something more up-to-date. The choice was fairly simple. Yes, Ubuntu. Praised by everyone, loved by many aka the most popular linux distro around.

I got to know a little bit of Debian magic, by installing apt-get for my RedHat. It had very limited use as the rpm repositories were rarely updated. Only using Debian you can experience its full potential. And yes, Ubuntu is a Debian clone.

The installation was fairly simple, although I missed the “select packages” screen (I suppose there is no option to choose the installed packages before the installation). Next stop: configuration. Turning off graphical login, disabling useless services (cups, alsa, ppp and so on…) – all the usual stuff. Hour after hour my system was shaping up.

At some point I have noticed that I did not have identd running. Without any hesitation I executed apt-get install oidentd. One minute later it was up and running.

And now for the magic part. It has automatically discovered the non-routable IP address (in the 192.168.x.x range) assigned to the eth0 interface (which was also the default routing target) together with the IP address of the gateway. Based on those two IP addresses it found out that my machine was sitting behind a NAT, so it automatically added the -A gateway_ip option to the command line (needed for oidentd to work behind a NAT). That’s just pure magic.

I know it’s just a relatively simple installation script, but still, it’s those simple things which make all the difference. And, sometimes, also make my jaw drop.

10 points for Ubuntu.

The story behind the Apple Graphing Calculator

I used to be a contractor for Apple, working on a secret project. Unfortunately, the computer we were building never saw the light of day. The project was so plagued by politics and ego that when the engineers requested technical oversight, our manager hired a psychologist instead. In August 1993, the project was canceled. A year of my work evaporated, my contract ended, and I was unemployed.

I was frustrated by all the wasted effort, so I decided to uncancel my small part of the project. I had been paid to do a job, and I wanted to finish it. My electronic badge still opened Apple’s doors, so I just kept showing up.

(…)

I asked my friend Greg Robbins to help me. His contract in another division at Apple had just ended, so he told his manager that he would start reporting to me. She didn’t ask who I was and let him keep his office and badge. In turn, I told people that I was reporting to him. Since that left no managers in the loop, we had no meetings and could be extremely productive. We worked twelve hours a day, seven days a week.

This is one way to make great software. Graphing Calculator shipped initialy on more than 20 million machines and is part of the OS X till this very day (in classic mode). Yet the project never officialy existed. Sounds like a fairy tale? It sure does. This is an exceptional story, that reminded me of Milton from Office Space.

via 37Signals / Wired

OS X running on an ordinary x86 PC

As they use to say, it was just bound to happen. Although many have said that it would not be possible, deep down in my heart I knew that one day some clever hack would make running OS X on a typical x86 machine possible. And so it has happened.

Apple Mac OS X running on Intel x86 PC

OS X PROVEN hacked and running on an ordinary PC

All in all, it does not appear to be a hoax as the installation instruction is very detailed.

The only downside is that it requires a pretty decent CPU to run (smoothly) and a helluva lot of disk space to install. That means no fun for me (yet!). But still, it’s a small step of one man and a big step for all humanity. Job well done!

UPDATE: Wired has more info about OSx86.

Thx Clint for the link!

New tag: to_wikiself

to_wikiself [vt]:
Reminder to put your name in a Wiki.

This was the shortest tag I could come up with for this particular activity. Although changing Wiki is usually a straightforward and simple process, which could probably be done without setting up any reminders, I have two distinct cases where I cannot put my name in a Wiki yet. First is the Ruby on Rails professional developers Wiki, listing those who get paid for working in Rails. I am certain, that in a foreseeable future, I will be able to put my name there. Just not yet, though.

The other one is a Hugh MacLeod wiki listing wine bloggers. I would like to put my client’s newsletter there (he runs a wine selling company called Wine Express), but I think this would be inappropriate as a newsletter is definitely not a blog. At this very moment I’m in the long process of converting it into something which is more like news but with allowed comments. As soon as it’s ready, I’ll put it in the aforementioned wiki.

And that’s basically it. And the funny thing is that absolutely no one in the whole wide world is using it (yet?). It’s 100% unique. Should I put a © copyright on it? Nah, didn’t think so. Should you find this tag useful, please feel free to use it. No royalty payments required. Really.

Hapland 2

Hapland 2 finished! Damn, it was hard. It took me countless efforts to figure out all of the quirks. And no, I did not cheat. I have spent countless hours on this game and it was well worth it! I said in my previous Hapland post, that it would probably take me about a month to finish Hapland 2. Actually it took me two and a half weeks, which is quite an accomplishment, I think, as the game is really hard (I know, I’m saying this all over again and again…). If you haven’t played it yet, you should definitely give it a try!

Play Hapland 2

And now for the thing that came here for:

Although I still think that walkthroughs spoil all the fun! And believe me when I say that I had lots of it!