• Ruby 1.9.2 on Ubuntu/Mint with no Fuss and no Muss

    Date: 2010.08.31 | Category: Development, Linux, Rails, Ruby, Tech Stuff | Tags:

    Okay, so I was wanting to try out the newly released version 3.0 of Ruby on Rails, and I didn’t want any of that old and slow Ruby 1.8.x series that has been the default for years in Kubuntu, and probably any other Debian-based distro (I’m on Mint Isadora right now, and it’s the same thing here).

    Why? Well, you can take that jRuby and stuff it, because even if it beats the 1.8.x MRI “vanilla” Ruby in performance, it comes nowhere near the x4 performance Ferrari run you get with Matz’ MRI Ruby 1.9.x. Besides, let’s move the fuck on people, the first preview of 1.8 was released in 2002, and 1.9 has been here for three years! Could we just try to not fall asleep, please?

    Well, anyway, as this isn’t the first time I’ve tried to go the 1.9 way with Kubunuxumutuntu, I kinda expected it to suck, because I’ve never seen it actually just install and run as “ruby”. I’d always add the packages I wanted using apt, then do ruby –version, and be greeted with the all to familiar,

    The program ‘ruby is currently not installed.  You can install it by typing:
    sudo apt-get install ruby

    …sigh. Thanks. Of course, this isn’t because ruby wasn’t installed, it’s because it’s installed as “ruby1.9.1″, gem is “gem1.9.1″, and so on and so forth. So do you go with the symlinking approach, possible breaking future package installs that try to install ruby 1.8.x as a dependency, do you try to configure your way out of it and aliasing commands in bashrc, or do you go Googling as usual?

    Of course I go Googling, and this time I was actually in for a couple of surprises. First of all, Rails doesn’t even support Ruby 1.9.1, if you want 1.9, you have to go with the brand-new version, 1.9.2! The missing support for 1.9.1 surprised me, because I’d thought “they’d come around by now, what with 3.0 and all”. Anyone who’s tried Railing on 1.9.1 will know that you’d get into some serious trouble getting the gems up and running. Sooner or later you’d be staring at a compiler error taking all the fun and future hopes out of it all.

    Second of all, I came across RVM, or the Ruby Version Manager. This sweet, sweet tool will not only automate the retrieval, compilation, and installation of any Ruby version available from Matz, IronRuby, jRuby or whatever, it will also do it non-intrusively, by installing everything in your home dir and no go fudging with system binaries that other, older, and quirky applications may depend upon.

    And get this: That’s not all of it, you can also install any number of different revisions to suit all kinds of crazy apps and setups you may have that needs it. Sounds fussy? Fuck no, it’s a piece of cake :) There are lots of other cool things it can do that, some that I don’t even understand, but either way, just go read about it, then go install it, and set up your Ruby version(s)!

    A couple of tips to add to what you read there:

    • The documentation claims you need to install a 1.8.x branch before any of the other versions, but I found that doing “rvm –install 1.9.2” twice with a ctrl+c when it starts to download 1.8.x on the first attempt will install just the 1.9.2 branch in the second attempt without any issues (yet).
    • You probably want to set a Ruby version as the default after you’ve installed. I did “rvm –default ruby-1.9.2“.
    • Remember to follow the directions on packages you need to install, and note that git-core should probably be installed before you start doing anything. You don’t really need vim, either, unless that’s your preference. I use Aptana.

    Let’s go Railing 3.0-style on the 1.9.2 Ruby branch motherfuckers! Yeah! :D

    EDIT: When installing gems, note that linecache and ruby-debug-base should be installed from “linecache19″ and “ruby-debug-base19″ for 1.9.x rubies. If you have issues while building mongrel, try “gem install mongrel –pre”. Also, http://isitruby19.com is worth consulting when something fails to install ;)