Building Ruby 1.9.0 on an Apple Mac

I decided to start playing around with the latest Ruby, 1.9.0, which was released on Christmas Day.  I am on a MacBook Pro running OSX Tiger 10.4.11.

I previously blogged about what to do with Ruby 1.9 to get up-to-speed. Anyone using Ruby today probably shouldn’t be considering overwriting their Ruby 1.8.6 installation if they do any real coding or have an existing code base. Many of the gems and libraries you use may not work with 1.9, Rails 2.0.2 for one does not.

Getting Started

The first thing I did was download the Ruby 1.9 source from Ruby-Lang, I copied the contents of this archive to a folder in my home directory called Source (/Users/rbazinet/Source). This way I keep all of my downloaded source organized and easy to manage.

Opening up a Terminal window and changing to that directory will get things started. Now to setup the build to not overwrite my installed version 1.8.6 of Ruby, I created a directory called ruby19 in my home directory.

$ autoconf
$ ./configure --prefix=/Users/rbazinet/ruby19
$ make

Of course nothing always works as planned. During the build I received the following error:

compiling readlinegcc -I. -I../../.ext/include/i686-darwin8.11.1 -I../.././include -I../.././ext/readline -DRUBY_EXTCONF_H=\"extconf.h\"    -fno-common -g -O2 -pipe -fno-common   -o readline.o -c readline.c
readline.c: In function 'filename_completion_proc_call':
readline.c:659: error: 'filename_completion_function' undeclared (first use in this function)
readline.c:659: error: (Each undeclared identifier is reported only once
readline.c:659: error: for each function it appears in.)
readline.c:659: warning: assignment makes pointer from integer without a cast
readline.c: In function 'username_completion_proc_call':
readline.c:684: error: 'username_completion_function' undeclared (first use in this function)
readline.c:684: warning: assignment makes pointer from integer without a cast
make[1]: *** [readline.o] Error 1
make: *** [all] Error 1

It appears readline is the problem here and needs to be updated. After a bit of searching around the net I can across some information about this and determine readline needs to be updated to readline 5.2.

Readline can be downloaded from I created a directory in my standard Source folder called readline-5.2 and then performed a build:

$ cd /User/rbazinet/Source/readline-5.2
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

Now with Readline 5.2 installed I tried the Ruby 1.9 build again, this time indicating the location of my new Readline installation:

$ autoconf
$ ./configure --prefix=/Users/rbazinet/ruby19 --with-readline-dir=/usr/local
$ make
$ make install

Changing to our new Ruby 1.9 installation directory:

$ cd /Users/rbazinet/ruby19/bin
$ ./ruby -v
ruby 1.9.0 (2007-12-25 revision 14709) [i686-darwin8.11.1]


We could add our new ruby/bin to path if we wanted, to make it a big easier to test, but for now this works.  I am running Tiger so I don’t know if this same procedure works on Leopard.  If someone can confirm if this works or can comment on how to build Ruby 1.9 on Leopard, I will update this post to reflect what is needed to be done.

Technorati Tags: ,,

8 responses to “Building Ruby 1.9.0 on an Apple Mac

  1. Glad you have no problem on tiger, there are too many problems building readline on leopard and ruby as well.
    I’m counting on apple to release a new security update that has ruby 1.9 as well.
    Also you might want to add –program-suffix=1.9 behind ./condigure, as lots of people using ruby on rails, the fast thread is not yet working with ruby 1.9

  2. @Yudi thanks for the info. It was a bit of challenge on Tiger but not bad. I hear Ruby 1.9 just does not work on Leopard yet.

    What exactly does the -program-suffix=1.9 do exactly? Is this strictly for fastthread?

  3. I’m having a problem with readline (5.2 and 5.1) on Ruby 1.8 that seems similar to this. I get the following error and two different scenarios:
    dyld: NSLinkModule() error
    dyld: Symbol not found: _rl_filename_completion_function
    Referenced from: /usr/local/lib/ruby/1.8/powerpc-darwin8.11.0/readline.bundle
    Expected in: flat namespace

    I’m using OSX 10.4.11. I tried installing readline 5.2 with the configure options above and it made no difference.

    Any ideas?

  4. @Claude Are you getting the error when building Readline or after when you try to build Ruby 1.9? I have seen some special cases on the web when building Readline on a PowerPC Mac. I assume this is what you are using?

  5. Hey thanks for the help. I really appreciate it.

    I’m having no trouble on the build. I basically followed the directions for the build that are at
    and that went fine as far as I could tell.

    When installing both Ruby and Readline, at the ./configure step, I used the ‘–with-readline-dir=/usr/local’ parameter

    Current installed versions on my machine are:
    Ruby 1.8.4 (2005-12-24) [powerpc-darwin8.11.0]
    Rails 1.2.5
    LightTPD 1.4.18
    MySQL 5.0.45-OSX10.4-powerpc-64bit
    FastCGI 2.4.0
    RubyGems 0.9.0
    Readline 5.2
    PCRE 6.6

    I get this error in two different scenarios:
    1) whenever I type irb from a command prompt

    2) when doing the exercise on p. 39 of the Prag Prog book Agile Web Development with Rails. When I point the browser to http://localhost:3000/say/hello the error message appears in the terminal window and the browser then hangs.

    Thanks again!!

  6. Looks like I fixed this problem. I found a discussion topic at that pertained to this issue.


    It appears that the trick was this: After installing, rebuilding Readline 5.2 in place of 5.1, then rebuild Ruby. But in the Ruby directory do a ‘make distclean’ prior to the configure, make, sudo make install steps.

    The ‘make distclean’ was the trick. I have no idea what that does, but that appears to be what solved the problem, along with installing Readline 5.2 in place of 5.1.

    Sorry to be such a bother, and thanks so much for your attention.

  7. @Claude Great news! You were no bother at all, this is what blogging and commenting is all about, collaborating.

    I thank you for following up and letting me know how you fixed it. I wondered if maybe a clean configure might do the trick. So the “make distclean” does that extra step. A new one for me too.

  8. thank you for following up and letting me know how you fixed it. I wondered if maybe a clean configure might do the trick. So the “make distclean” does that extra step. A new one for m

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s