Tiger the new version of OSX for Macs comes installed with the latest and grates Ruby, version 1.8.2. However there are a few problems with it. Under Panther I had used Marks ruby package
The case of the missing readline
The largest and probably easiest solvable problem is the lack of readline support, which meant that irb (Interactive Ruby) doesn’t work. Apple didn’t include readline allegedly because of license issues, but I don’t quite get that as they include gcc and other gpl/lgpl tools. There is a libreadline in /usr/lib, however it is symlinked to libedit and ruby’s irb didn’t seem to like it.
So my job number one was to get hold of readline. I first tried building it from scratch and got some wierd errors:
gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4061)
powerpc-apple-darwin8-gcc-4.0.0: -compatibility_version only allowed
with -dynamiclib
make[1]: *** [libreadline.5.0.dylib] Error 1
make: [shared] Error 2 (ignored)
As I’m a mac nuby this went a bit over my head. I started a quest of reading up on the jois on dylib, library bundles etc. Which I still don’t quite understand.
In the end I ended up using DarwinPorts which I recommend. This installed readlines without a problem.
I then did a manual configure and built just the readline module:
./configure --prefix=/usr
cd ext/readline
make
sudo make install
This just builds and installs the readline support into the existing ruby library.
Rake sans database == bad rake
Now irb would work. However running rake on my rails projects gave me an even stranger problem.
No database selected: SHOW TABLES
I got this from within rake where it would happen as it was trying to setup the database for the unit tests. At first I thought rails in it’s entirety had a problem with the database, but running the server I realised it ran fine.
I’m pretty religious about unit and functional testing in my rails apps, so this was obviosly a problem.
I still haven’t found out exactly where the problem lies, but I ended up just building my own ruby and placing it in /usr/local just like Marks. This works just fine.
./configure --prefix=/usr/local
make
sudo make install
Remember to place /usr/local/bin at the beginning of your path by editing /etc/profiles.
This entry was posted in the following Categories: Ruby , mac
I don't have Tiger yet, but hopefully the comments will help.
I avoid worrying about /usr/local/bin vs. /usr/bin by using "#! /usr/bin/env ruby". The env program finds Ruby in your path. (I de-installed /usr/bin/ruby, but env will find the first Ruby in your path.)
As for Rake and your database problems, did you re-install your Ruby database drivers? When I upgraded my Ruby, it created new directories in /usr/local/lib/ruby/1.8 and /usr/local/lib/ruby/site_ruby/1.8 called something like powerpc-darwin0.7.8 (that's from memory). There were already older directories with similar names (something like powerpc-darwin0.7.7), and the database driver .so and .dlib files were in the older directories. Once I moved them to the newer directories, my database access worked just fine again.
I'm looking forward to Tiger.
Posted by: Jim Menard on April 18, 2005 08:29 AMWhy even build your own Ruby? Seems like you could just reinstall Mark's Mac Ruby package again, since it installs in /usr/local anyway.
Posted by: Andrew on April 18, 2005 10:37 AMI'm pretty sure that the Panther Ruby package will not be compatible with Tiger. When I get a copy of Tiger, I'll be updating the packages.
Posted by: Mark Hubbart on April 18, 2005 12:07 PMI've built an installer package that fixes Tiger's ruby, and installs a working version of rails (with fcgi and mod_fcgi for the inbuilt apache server).
Try it out if you'd like: http://wiki.rubyonrails.com/rails/show/HowtoInstallOnOSXTiger
Posted by: Tony Arnold on April 29, 2005 05:26 AMTry Windows - Ruby is a simple one-click install.
You'll get much faster hardware for your money, too.
I tried Ruby/Rails on Mac, and after much hassle and screwing about it worked. Getting sick of my half-gig memory mac mini's sluggish performance though - the eye-candy honeymoon appears to be becoming over.