Troubleshooting
This page tries to enumerate frequently asked questions regarding well-known Ruby issues on Mac OS X. If your problem isn't described here, feel free to [contact us].
I cannot build ruby-mysql on Leopard with mysql.com binaries
If you get a build problem when trying to build the ruby-mysql library, either manually or via its gem, it is perhaps because Ruby in Leopard tries to build its C extensions universally (for both the Intel and PowerPC architectures), and that the version of MySQL that is in your system isn't universal.
MySQL binaries that you can download from the mysql.com website are for the moment delivered per-architecture. They don't provide universal binaries.
The solution is to set the ARCHFLAGS environment variable to your native architecture before building the Ruby extension. Ruby will use the content of this variable when building.
As an example, if you are building the C extension manually, on an Intel machine:
$ ARCHFLAGS="-arch i386" ruby extconf.rb --with-mysql-dir=/usr/local/mysql $ make $ sudo make install
(If you build on a PowerPC architecture, replace -arch i386 by -arch ppc.)
If you are installing the gem, you need to know that in Leopard sudo doesn't transfer by default environment variables to the privileged process. You can work around this by spawning a root shell:
$ sudo -s $ ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql
Now that you successfully installed the Ruby bindings, there is another trap. If you try requiring the extension, you might get:
/Library/Ruby/Site/1.8/universal-darwin9.0/mysql.bundle: dlopen(/Library/Ruby/Site/1.8/universal-darwin9.0/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib (LoadError) Referenced from: /Library/Ruby/Site/1.8/universal-darwin9.0/mysql.bundle Reason: image not found - /Library/Ruby/Site/1.8/universal-darwin9.0/mysql.bundle
The libmysqlclient.dylib version that is currently provided by mysql.com seems to have a wrong install name:
$ otool -L /usr/local/mysql/lib/libmysqlclient.dylib /usr/local/mysql/lib/libmysqlclient.dylib: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib (compatibility version 16.0.0, current version 16.0.0)
The correct path should be /usr/local/mysql/lib/libmysqlclient.15.dylib instead. Fixing this problem is trivial, by creating a symbolic link:
$ sudo ln -s . /usr/local/mysql/lib/mysql
It is still unclear why this install name problem doesn't seem to occur in Tiger or below. We will investigate more and report updates in this article.
can't find header files for ruby
If you get the can't find header files for ruby error message when trying to build an extension or a gem, it means that Ruby cannot locate its header files.
Header files are not delivered by default with Mac OS X, you need to install the Xcode Tools package after the installation. You can find it in the Optional Installs / Xcode Tools directory on the Leopard DVD.
RubyInline 3.6.4 or below doesn't work
This problem has been fixed in Mac OS X 10.5.2, or in RubyInline 3.6.5
If you get a CompilationError exception when trying to use RubyInline on Mac OS X, it is because the version of Ruby that is delivered with Mac OS X was built with custom compilation flags, that do not include -undefined suppress. Ruby by default will use this flag, which ignores missing symbols when linking.
A temporary solution is to edit the lib/inline.rb file that is part of the RubyInline project, and replace:
flags = @flags.join(' ')
With:
flags = @flags.join(' ') + ' -lruby'

