Blogging this more for my own record, but maybe others will find it useful... Tonight I was having a hard time getting the MySQL Ruby Gem installed on a new MacBook Pro. I have installed Ruby, Rails, RubyGems, MySQL, etc. via MacPorts (or via the Ruby that was installed via MacPorts). Anyway, this is the command that finally got it to work:
sudo gem install mysql -- --with-mysql-include=/opt/local/include/mysql5 --with-mysql-lib=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
Update: as I mention in my comment below (updating here in case folks don't read the comments), when doing this on Leopard/MacOS X 10.5, I needed to change it to:
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-include=/opt/local/include/mysql5 --with-mysql-lib=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
24 September 2007
Installing Ruby MySQL Gem with MacPorts MySQL
Posted by Chris at 9:01 PM
Labels: MySQL, Rails, Ruby, RubyOnRails
Subscribe to:
Post Comments (Atom)
19 comments:
I had the same problem and googled "macports mysql gem" and your post was first on the list. I'm sure others will find this helpful too. Works perfectly. Thanks!
it work!!
this worked perfectly for me, many thanks.
Note, when doing this on Leopard/MacOS X 10.5, I needed to change it to:
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-include=/opt/local/include/mysql5 \
--with-mysql-lib=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
Thanks for the heads up on the gem install, and thanks for adding in the "arch" item as well - that got it for me on Panther.
Don't know why my install needed a slightly different version: sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-include=/usr/local/mysql/include --with-mysql-lib=/usr/local/mysql/lib --with-mysql-config=/usr/local/mysql/bin/mysql_config
Thanks a ton, this was very helpful.
i luv u anonymous man
worked great. cheers.
To anonymous who used the /usr/local/... tree, my guess is that you previously had the binary mySQL from mySQL installed as that sits in the /usr/local/mysql directory. Otherwise, a fresh install of mySQL on a new mac would not have any files there.
Very helpful post. Thx a lot!
Worked perfectly for Leopard! Thx
excellent stuff, solved the problem for me.
nice blog my the way, you've got some impressive stuff there.
John.
Thank you for posting this!!! Hugely helpful.
yes, worked. also if you get an error after the gem installs properly like this
dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
do one of these
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
and you're golden.
Thank you!
Awesome! Just what I needed! Thanks so much!!!
Awesome tip, thanks
Post a Comment