Passenger error “library not loaded”

2020-06-30 03:51发布

问题:

Getting this error from Passenger (with Apache). Not sure what it means...

 dlopen(/path/to/myapp/shared/bundle/ruby/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): 
 Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib 
 Referenced from: /path/to/myapp/shared/bundle/ruby/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle 
 Reason: image not found - /path/to/myapp/shared/bundle/ruby/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

The Ruby installed is actually 1.9.2 but the gems are in this "1.9.1" path for whatever reason...

Could it have something to do with the fact I'm using the mysql2 gem instead of mysql?

Or, maybe could it have something to do with the 2nd line "Library not loaded" where it looks like it might be trying to load the wrong libmysqlclient.16.dylib? As the path /usr/local/mysql points to a version of mysql that is not running. The version of mysql that is running is in /usr/bin/. I'd try to change this but I have no idea how!?!

回答1:

The announcement for Ruby 1.9.2 says (sic)

This version is "librariry compatible version". Ruby 1.9.2 is almost 1.9.1 compatible, so the library is installed in 1.9.1 direcotry.

That is why the ruby directories are named “1.9.1”; it is normal.


Your instance of the mysql2 gem was built against the /usr/local/mysql/lib/libmysqlclient.16.dylib library. For one reason or another, that library is not currently available on your system at that pathname (MySQL removed/moved/upgraded?).


You probably need to rebuild your mysql2 gem and point it to the mysql_config (or mysql_config5) from your MySQL installation (in /usr/bin?):

gem install mysql2 -- --with-mysql-config=/usr/bin/mysql_config