NSLinkModule error w/ recent MacPorts Ruby and binary MySql install

13 views
Skip to first unread message

Sam Smoot

unread,
May 27, 2007, 1:24:01 PM5/27/07
to DataMapper
Ok, so you install the MacPorts and MySql binaries on your Mac.

You add the mysql/bin path to your .profile so you can use the command-
line-tools:

export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:
$PATH

You then install ruby:

sudo port install ruby rb-rubygems

You then install the mysql gem:

sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

You setup your happy rubygems require overwrite by adding these to
your profile:

export RUBYLIB="/opt/local/lib/ruby/site_ruby/1.8/"
export RUBYOPT="rubygems"

Then reload the profile:

source ~/.profile

Drop into irb and try to require "mysql" and you end up with this
error if you have a *37 build of Mysql:

irb(main):001:0> require 'mysql'
dyld: NSLinkModule() error
dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.
15.dylib
Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/
mysql.bundle
Reason: image not found
Trace/BPT trap

Here's the fix.

Run this in a terminal window:

sudo install_name_tool -change /usr/local/mysql/lib/mysql/
libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /
opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle

You should be able to require 'mysql' now.

Adapted from a RailsForum post here: http://railsforum.com/viewtopic.php?pid=23125#23125

Reply all
Reply to author
Forward
0 new messages