Since moving to Mac, I always find it surprising that the default Mac OS X Ruby and IRB doesn’t allow inputs with accented characters. So, you cannot do
name = "George Guimarães"
This is annoying for brazilians and anyone who uses non-ASCII characters. The problem is that the default Ruby in Mac OS X isn’t linked against readline. A simple solution is to compile readline on your system, and then compile your own ruby binaries. A better one is to use tools that automate this process.
If you use Homebrew (and you *should*), just do
brew install readline brew link readline
Beware: linking readline into your system may break other tools that depends on readline source to compile. It was harmless on my system.
Ok, so now we want to build a new ruby and irb binaries. I wanted to use ruby 1.8.7-p248, so:
rvm install 1.8.7-p248 -C --enable-shared,--with-readline-dir=/usr/local
This tells the configure script to enable shared library linking (it is the default), and to search for readline in
/usr/local (homebrew has just linked readline there). You may have to use
--force if you already have this ruby version compiled. Newer versions of RVM do not need
Now you can use accented and unicode characters on keyboard input in IRB using ruby 1.8.7.
English. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.