TAGS :Viewed: 8 - Published at: a few seconds ago

[ Rake db:create fails on Library not loaded ]

I was running PostgreSQL 9.1, installed from Postgres (/Library/PostgreSQL/9.1) - ie not homebrew etc and on Mac OSX Leopard.

I upgraded to Snow Leopard and then immediately to Mountain Lion and had a mass of problems with gems failing to build etc, but got them fixed

Rails server crashed on startup with pg issues & I tried everything I could find but could not fix the prob - fixes included links etc, which may still persist (hence this background info might inform the solution)

I uninstalled postgresql 9.1 and installed Postgres App

Now on rake db:create I get the following:

rake aborted!
dlopen(/Users/mitch/.rvm/gems/ruby-1.9.2-p320@tme-3.2.11-mltest/gems/pg-0.17.0/lib/pg_ext.bundle, 9): Library not loaded: @loader_path/../lib/libpq.5.dylib
Referenced from: /Users/mitch/.rvm/gems/ruby-1.9.2-p320@tme-3.2.11-mltest/gems/pg-0.17.0/lib/pg_ext.bundle
Reason: no suitable image found.  Did find:
/usr/local/lib/libpq.5.dylib: mach-o, but wrong architecture - /Users/mitch/.rvm/gems/ruby-1.9.2-p320@tme-3.2.11-mltest/gems/pg-0.17.0/lib/pg_ext.bundle

I'm running rvm (as u can see) and after the OS upgrade created a new gemset and installed Ruby

I've changed my path to reflect the advice of Postgresql App, after the OS upgrade I installed Xcode 5 and the command line tools as advised and I think my database.yaml file is ok

I suspect the problem might be connected with sym-links made earlier in the process, but I'm stuck to find the solution

Answer 1


Sounds like something has gone wrong in your Ruby installation. Try reinstalling Ruby Enterprise Edition via RVM:

rvm reinstall ree

Answer 2


I was experiencing the same issue with a different version of libpq. What I ended up doing is creating a link to the correct file:

sudo ln -s /Applications/Postgres93.app/Contents/MacOS/lib/libpq.5.6.dylib /usr/local/lib/

My previous answer was deleted as it wasn't originally an answer, just a confirmation of a similar issue. Hope this helps!

Answer 3


In the end I think this was tied up with the fact that Mountain Lion ships with Postgresql rather than MySQL as per previous OSX versions.

I couldn't make sense of the Postgres App, so I uninstalled it and also uninstalled the version of Postgresql that shipped with ML and then did a Homebrew install of the latest version of Postgresql (which places it in a different place than if you install it direct from the Postgresql site).

This seemed to straighten everything up