Raging at Ruby on Rails

Raging at Ruby on Rails

As usual, I have been bored (not that there’s a lack of things to do – but one requires stimulation – and not in the sexual kind of way, although I definitely wouldn’t say no), so I decided to look at Ruby on Rails.  Admittedly I’m probably a complete moron when it comes to looking things up, per se, but I battled to find decent beginner information on rails, and ruby and how everything fits together in the scheme of things. Sure, there are ruby tutorials, and rails tutorials, but I just couldn’t find anything that actually made sense to my warped frame of mind. I did quite a bit of googling, clicking on links from rubyonrails.org and ruby-lang.org, and reading of pages and such.  I even subscribed to some podcasts.

Eventually I figured out that Phusion Passenger was the correct way to run Rails applications on Apache, so I looked into installing that.  Unfortunately Phusion passenger requires apache2-mpm-worker which allows apache to use multiple threads. It completely replaces apache2-mpm-prefork, the default non-threaded model which the apache php5 module requires. And since everything on my web server is php based, this presented a problem. Fortunately it’s not a huge problem, as the workaround is to set up php5-cgi using FastCGI, which actually has more pros than cons. It’s definitely a better way to run php – the speed boost was definitely noticeable to me, and I didn’t pick up any issues with any of the sites.  Fortunately it didn’t take me too long to convert the sites to use FastCGI. Downtime was less than 5 minutes.

I then installed ruby, and rails from the stock repositories. Turns out this wasn’t a great idea, as by default it was ruby 1.8… and I’m obsessed with using the latest version of things. So I installed ruby 1.9. Then I discovered that it still wasn’t the latest, and it wasn’t in the repository.  So I upgraded my server OS to the latest release. And it had ruby 1.9.1. And even that patch level wasn’t even close to the latest version.

In the mean time, I found http://railstutorial.org. The newest tutorial deals with Rails 3.0, which is currently at version 3.00rc, and when you install that version of rails, it warns you that it may not function correctly with version 1.9.1 and to rather install 1.9.2 when it was released. Fan-bloody-tastic. I went ahead anyway, but had some issues getting the app to run properly. I kept getting odd errors, and there were messages about the app not finding certain gems that were, in fact, installed. It was painful.

So I figured, what the hell. I’d remove the OS-provided ruby and all the little bits and bobs, and I would compile ruby from scratch, and install it using checkinstall, so I could at least remove it.

I grabbed the most recent version (1.9.1p429 at the time) off ruby-lang.org, and tried to compile it, but received a compiler error. Googling told me I should try doing make optflags=-O3. That worked, but I got another error further along. Googling again told me that I should try running ./configure –enable-shared. So I did, and I ended up with a compiled ruby. I ran make install via checkinstall, and I was happy.

Actually, not. For some reason I checked the ruby-lang site, and discovered that the latest patch release was now 1.9.1.p430. What the…? It had been p429 just minutes ago, I swear!  I even thought that maybe I had actually downloaded p430, but the internal version number perhaps hadn’t changed… but I checked the downloaded archive, and it was definitely p429, the version.h said so.  So I downloaded the p430 archive, checked the version.h – it’s patch level 430. So I compile it. I run ./ruby -v. It returns 1.9.1-429.

Now I was incredibly confused. I grab the nightly snapshot. The version.h says it is version 1.9.3. Compile it, and run ./ruby -v. Also version 1.9.1-429.

I realised that it must be reading something from the installed version of ruby, so I remove it, and run ./ruby -v.  It returns an error about not finding libruby-1.9.1.so.

After a lot of thinking and considering, I decided that my best plan of action would be to grab a nightly build, and setup a package build via checkinstall. So I did just that. Although I think after this whole exercise, I’ve compiled ruby about 20 times now. But at least I now have a decent script that pretty much automates the getting, compiling and building of the package.

And I have a test site gurgling quite nicely under phusion passenger (mod_rails/mod_rack).

Of course, I’m leaving out a fair amount of detail about researching other frameworks and testing those out. The swearing about getting passenger to do what the docs say it should do (the OS-distro of it was old. Typical), and that kind of thing.  At least now I should hopefully be in a position to start actually learning how to use Rails via that tutorial I mentioned earlier.