1. Mar
    01

    Installing ruby 1.9.2 and sinatra 1.0a

    Posted in : ruby and sinatra

    It would be sacriledge to use the old and dusty ruby 1.8.7 and stable as a dead cow sinatra version 0.9 for our experiments. Jump the wagon for cutting edge ruby 1.9.2 and sinatra 1.0a, and enjoy the speed improvements they both provide.

    Install rvm

    If you don’t use it yet, it’s probably time to install rvm. On Mac OS X, ruby is installed as part of the system, but you will need a compiler. The Developer Tools are on installation dvd provided with each Apple computer (usually the first thing to install on a fresh Mac OS X if you’re a developer), just remember the last version is always the prefered choice (free registration mandatory to download it from Apple). To install rvm using gem, open your terminal and type:

    gem install rvm --source=http://rubygems.org/
    rvm-install
    

    Follow the instructions, check the given lines have been added successfully in your ~/.profile (or ~/.zshrc if you’re using zsh) or copy/paste them manually. Then open a new tab.

    To check that you’ve rvm type:

    rvm list
    

    It should show you the system ruby provided by Xcode and no other version yet.

    Install ruby 1.9.2

    Once you have rvm it’s easy. However, there’s a catch. The ruby version we want doesn’t appear in the list (at least at time of writing) if you do:

    rvm list --all
    

    Ruby 1.9.2 preview 1 has some serious issues, we expected at least preview 2. The fun part is that it’s still possible despite the fact that it’s not in the list, just do:

    rvm install 1.9.2-head
    

    After a few minutes, you’ll have it installed. You still need to tell rvm that you want to switch to this version, just type:

    rvm 1.9.2-head
    

    It will only change used ruby version inside the current tab. It’s perfect if like us you just want to try it out. If however you want it to replace the system ruby as your default ruby, just type:

    rvm 1.9.2-head --default
    

    Caveat

    When running on Mac OS X 10.6 (Snow Leopard) on a 64bit architecture Ruby 1.9.2-head still generate a segfault intermittently (see: Non systematic segmentation fault with autoload rubyspec). If you have the problem, you can revert to ruby 1.9.1:

    rvm install 1.9.1
    rvm 1.9.1
    

    Install sinatra 1.0a

    Sinatra 1.0 is coming and has numerous benefits such as template caching. Until final release, you can install version 1.0 alpha with:

    gem install --pre sinatra
    

    Conclusion

    You should now be up and running with ruby 1.9.2 and sinatra 1.0 - and in my tests they proved to be pretty stable while giving a real speed boost. There’s no reason not to try them yourself unless you depend on a load of not-yet-compatible gems or plugins.

    Comments