I've got a problem trying to install the Ruby mysql gem driver.
I recently upgraded to Snow Leopard and did the Hivelogic manual install of MySQL. This all seems to work fine as I can access mysql from the command line and make changes to the database.
My problem is that if I now use
rake db:migrate
I get:
rake aborted!
uninitialized constant MysqlCompat::MysqlRes
(See full trace by running task with --trace)
Now it appears that my mysql gem isn't working correctly as I can access MySQL fine from Python using the Python driver (which I compiled to). I therefore tried to rebuild the gem using the following command from this site: http://techliberty.blogspot.com/, (incidentally I am using a recent Intel MacBook Pro):
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
This compiles although I get No definition for the documentation:
Building native extensions. This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
No definition for next_result
No definition for field_name
...
I'm a little stumped as my mysql_config is located in the correct place:
/usr/local/mysql/bin/mysql_config
And I have removed all other instances of the mysql gem, from my system.
Any suggestions would be greatly appreciated. Many thanks.
PS I saw this previous post uninitialized constant MysqlCompat::MysqlRes (using mms2r gem) but it doesn't seem applicable for my version.
Basically the problem is the the dynamic library libmysqlclient can't be found. The above solutions will work, but you need to reapply them any time you rebuild the gem, or when you install a new version of MySQL.
An alternative approach is to add the MySQL directory containing the library to your dynamic load path. Putting the following in my .bashrc file solved the problem:
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With