Software Developer

+44 (0) 7590 538 303

46 Hill Street
Belfast, Northern Ireland

Upgrading to Ruby 1.9 and Rails 3.2.0.rc2

19 Jan 2012 {View Comments}

Last year was a long year of upgrades for a lot of our clients at [Rumble Labs](http://rumblelabs.com). Going into this year, most of our Ruby work is all running on Ruby 1.9.2. A lot of those projects are Rails applications and we managed to have most of those running on Rails 3.0.x. From an OCD point of view, this pleases me. Some of the applications we're working on for clients are now pretty big, Rails is getting bigger and there are more libraries out there. The combined effects of which are starting to feel a little slow. ## Ruby 1.9.3 [Ruby 1.9.3](http://www.ruby-lang.org/en/news/2011/10/31/ruby-1-9-3-p0-is-released/) is the latest stable release of the 1.9.x series. It's been great to start taking advantage of a few of the niceties in Ruby now since the move from 1.8.x. With Ruby 1.9.3 it's all about the speed. I tested running `time rake -T` before and after the upgrade in a number of our projects. Roughly speaking I saw a reduction of 50% in the time it took. This is **great!** If you use [RVM](http://beginrescueend.com/) (and I would recommend you do, or something like it) you can install with the following rvm install 1.9.3 ## Bundler A quick aside in case you haven't heard. The latest beta version of bundler is super fast compared to the current stable release. You can install the latest version of bundler (in your global gemset) with the following. rvm gemset use global gem install bundler --pre ## Rails 3.2.0.rc2 The latest version of [Rails 3.2.0.rc2](http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released) has a few changes, the biggest of which is some performance improvements to boot time, development mode and asset compilation. For our applications running on 3.1 it was quite a painless upgrade (unlike going from 3.0.9 -> 3.1). # add to your Gemfile gem 'rails', '3.2.0.rc2' # I like to create a new gemset for each specific Rails version rvm gemset create rails-3-2-0-rc2 bundle update ## Heroku What would be the use of upgrading all these apps if we can't try them out, in production! Thankfully it is possible to run both Ruby 1.9.3 and Rails 3.2.0.rc2 in production on [Heroku](http://www.heroku.com) thanks to their new **Heroku Labs** features, specifically their [user_env_compile](http://devcenter.heroku.com/articles/labs-user-env-compile) which allows us to set configuration that will be respected by the heroku build packs. **Note: not for the fainthearted** Heroku mention they may remove any feature of Heroku Labs without warning, so be careful! # Enable Heroku Labs heroku plugins:install http://github.com/heroku/heroku-labs.git # Enable the user_env_compile add-on (for each app) heroku labs:enable user_env_compile -a myapp # Enable 1.9.3 heroku config:add RUBY_VERSION=ruby-1.9.3-p0 That should be your Heroku app enabled to run on Ruby 1.9.3. Next time you push to heroku you should see something like the following in the compile output. -----> Heroku receiving push -----> Ruby/Rails app detected -----> Using RUBY_VERSION: ruby-1.9.3-p0 ## Conclusion I've upgraded about 10 apps so far and have yet to come across any showstopper bugs. It doesn't take too long to do either. So, definitely worth the performance improvements you will gain! Happy upgrading.