I just installed PostgreSQL and the pg gem for running Rails on Heroku. I'm running
$ rake -T
But it's aborting for reason related to "libpq.5.dylib"
rake aborted!
dlopen(/Library/Ruby/Gems/1.8/gems/pg-0.13.2/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib
Referenced from: /Library/Ruby/Gems/1.8/gems/pg-0.13.2/lib/pg_ext.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/pg-0.13.2/lib/pg_ext.bundle
What gives?
How can load the libpq.5.dylib library?
I am on a Mac. Here is what I did to get it working.
cd /Library/Ruby/Gems/1.8/gems/pg-0.13.2/lib/
otool -L pg_ext.bundle
libpq.5.dylib (compatibility version 5.0.0, current version 5.4.0)
Notice that libpq.5.dylib doesn't use an absolute path like the other libs in pg_ext.bundle. The system can't find it. You need to change where it looks for libpq.5.dylib.
install_name_tool -change libpq.5.dylib /Library/PostgreSQL/9.1/lib/libpq.5.dylib pg_ext.bundle
Note: Use the absolute path that applies to your system. I used what it was for my system.
Now run:
otool -L pg_ext.bundle
Notice what libpq.5.dylib points to now:
/Library/PostgreSQL/9.1/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.4.0)
The pg gem should be happy now.
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