Rails 3 with RVM FTW!

I’ve been playing a lot with Rails 3 lately, it’s completely awesome! However, we don’t have any Rails 3 app in production at the moment, all projects that Plataforma has been doing for its clients so far are using Rails 2.3.5. Since I was already having fun with Rails 3, I thought I should also give ruby 1.9 a try. Ok, so how could I have Rails 2.3.5, Rails 3, ruby 1.8.7 and ruby 1.9 in my machine without going crazy? The answer is RVM (Ruby Version Manager)!

RVM is an awesome tool that gives you the power to have as many rubies in your machine as you want, and the best of all, all versions are isolated, no conflicts at all. In order to install it, follow the instructions inside RVM’s site. After that, I installed ruby 1.9.1 through RVM with rvm install 1.9, installed all the gems necesssary to play with Rails 3 (gem install rails --pre) and then, I could start to play.

I was playing with that configuration successfully until the moment I got a segmentation fault error. Other people got the same error too. Thankfully the problem didn’t last too long, this was one of these moments which I was very happy for having a Rails Core member in my team (@josevalim). He told me that Rails 3 doesn’t support ruby 1.9.1, actually, it’s supporting ruby 1.9.2! So, I needed to install a new ruby version, and install all Rails 3 gems again, damn it! But, I was fortunate enough for being using RVM.

In order to install Ruby 1.9.2-head and Rails 3 gems, all I needed to do was:

  1. Update my RVM: rvm update --head
  2. Install ruby 1.9.2 head: rvm install 1.9.2-head
  3. Create a Rails 3 RVM gemset: rvm --create use 1.9.2-head@rails3
  4. Copy my already installed Rails 3 gems to my new RVM gemset within my ruby 1.9.2: rvm gemset copy 1.9.1 1.9.2-head@rails3

That’s all! After that, I was back to the game! Man, RVM is awesome!!!

Be sure to have a look at a Wayne’s gist about how to install Rails 3 with RVM, and, check out RVM’s Gemsets feature, it’s very useful.

And you, do you have any tips about dealing with many versions of ruby and/or Rails, or about RVM?

  • http://plentz.org Diego Plentz
  • http://plentz.org Diego Plentz
  • http://iain.nl iain

    I like the .rvmrc files. Automatically switch to the proper ruby version with the gemset specific to that project. Always a clean environment!

    http://rvm.beginrescueend.com/workflow/rvmrc/

  • http://iain.nl iain

    I like the .rvmrc files. Automatically switch to the proper ruby version with the gemset specific to that project. Always a clean environment!

    http://rvm.beginrescueend.com/workflow/rvmrc/

  • http://www.DrinkRails.com Sohan

    Your post has been linked at the drink#42

  • http://www.DrinkRails.com Sohan

    Your post has been linked at the drink#42

  • tom

    Thanks! I missed the note on the rails blog about the segfaults and your post got me up and running again.

  • tom

    Thanks! I missed the note on the rails blog about the segfaults and your post got me up and running again.

  • http://sickill.net/ Marcin Kulik

    Hi,

    What is actually not working under ruby 1.9.1? Which part of Rails3? I’ve successfully moved my Rails 3 app to ruby 1.9.1p378 and it’s working in production for a week now (http://kanbanery.com) without any problems. I’m not using ActiveRecord but DataMapper instead, so maybe the code which requires 1.9.2-head lays in AR….

  • http://sickill.net/ Marcin Kulik

    Hi,

    What is actually not working under ruby 1.9.1? Which part of Rails3? I’ve successfully moved my Rails 3 app to ruby 1.9.1p378 and it’s working in production for a week now (http://kanbanery.com) without any problems. I’m not using ActiveRecord but DataMapper instead, so maybe the code which requires 1.9.2-head lays in AR….

  • José Valim

    @Marcin, Rails 3 segfaults when using Ruby 1.9.1. We could not identify which part of the framework (or its dependencies) were causing the failure.

    If you have some time, try to deploy a basic application with one scaffold in this same server and same ruby version, but using ActiveRecord and please tell us if it segfaults or not. :)

  • José Valim

    @Marcin, Rails 3 segfaults when using Ruby 1.9.1. We could not identify which part of the framework (or its dependencies) were causing the failure.

    If you have some time, try to deploy a basic application with one scaffold in this same server and same ruby version, but using ActiveRecord and please tell us if it segfaults or not. :)

  • http://sickill.net/ Marcin Kulik

    @Jose,

    I’ve just created two fresh apps, one on sqlite, second on mysql. I’ve generated scaffold, migrated and run webrick. Then I’ve been adding, editing, removing posts and everything was working fine.
    Check out this gist for steps I’ve taken: http://gist.github.com/384972

    I’m using ArchLinux (32-bit) and rvm.

  • http://sickill.net/ Marcin Kulik

    @Jose,

    I’ve just created two fresh apps, one on sqlite, second on mysql. I’ve generated scaffold, migrated and run webrick. Then I’ve been adding, editing, removing posts and everything was working fine.
    Check out this gist for steps I’ve taken: http://gist.github.com/384972

    I’m using ArchLinux (32-bit) and rvm.

  • Arno.Nyhm

    i did not tested it but this command look it is for copying gemsets:

    http://rvm.beginrescueend.com/gemsets/copying/

  • Arno.Nyhm

    i did not tested it but this command look it is for copying gemsets:

    http://rvm.beginrescueend.com/gemsets/copying/

  • http://monsterboxpro.com Andrew Brown

    I’m really enjoying RVM, how we lived without it before. I have no idea.

  • http://monsterboxpro.com Andrew Brown

    I’m really enjoying RVM, how we lived without it before. I have no idea.