A few hints when upgrading to Ruby 1.9

Note: If you are currently working with Ruby 1.8.7 or 1.9.3, we recommend to upgrade to Ruby 2.1 first. From our experience this upgrade is much smoother than the jump from 2.1 and 2.2, while still giving your the huge performance gains of Ruby 2. Also, if you're on Ruby 1.8.7, we recommend to skip a troublesome upgrade to 1.9.3 and go straight to 2.1.


When trying to make a Rails app run on Ruby 1.9, you're likely to encounter several issues. Here are a few solutions (obviously not exhaustive):

When running bundle install, a gem called linecache complains about not being compatible

This is a dependency of ruby-debug. Use debugger instead. If you want your Gemfile to work for every version of Ruby you can also say:
^
gem 'ruby-debug', :platforms => :ruby_18
gem 'debugger', :platforms => :ruby_19

Your application throws "wrong number of arguments" errors

This is probably caused by a lambda not taking the right number of parameters. If you change it to a proc it will not complain any more.

Your app throws "invalid multibyte char" errors

You need to set the encoding of your .rb files by putting a
^
# coding: utf-8

comment into the first line.

You can use the attached "prepend_encoding" script to automate this with
prepend_encoding **/*.rb

Your app throws "incompatible character encoding" errors

This happens when non-UTF8 and UTF8 strings collide.

Make sure to you database and database table charsets to UTF8. You can check in the MySQL console with
SHOW VARIABLES LIKE "character_set_database";
SHOW TABLE STATUS;

Also update your nbsp helper if you use that.

Tobias Kraze Over 12 years ago