I have serious problem with Ruby and OSX Lion - whenever I try to start Rails or even a rake tool I am getting this error:
[FATAL] failed to allocate memory
I had a conflicting package mysql-connector-c
from homebrew installed. mysql2 used the dylib from this package and not from the mysql install.
Removing the homebrew package yielded another problem, which could be solved by adding
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"
to my environment.
It took me some time to figure it out but here is the solution:
This problem was caused by mysql2
gem, when I switched to ruby-mysql
it all started working again (remember to change adapter from mysql2
to mysql
in your database.yml
!)
So I started thinking about differences between mac mini and iMac. Basically the mini is running Lion upgraded from Snow Leopard, which is upgraded Leopard and it has good, old Mac Ports for mysql and pgsql servers. So when gem is compiled its using port libraries.
On the other hand the iMac with fresh Lion installation has Zend Server package (apache + php + mysql binaries) and a Homebrew package 'mysql-connector-c' that has libraries needed to compile gem.
All in all it seems as if ports version of mysql works correctly whereas Homewbrew connector does not (its leaking some memory?).
Hope this helps.
I uninstalled mysql2
$ gem uninstall mysql2
And reinstalled via bundler
$ bundle
And I'm able to rails s
once again