Read more

A few hints when upgrading to Ruby 1.9

Tobias Kraze
July 22, 2011Software engineer at makandra GmbH

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.


Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

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.

Posted by Tobias Kraze to makandra dev (2011-07-22 10:54)