I am working on a rails app.
Installed Postgresql using postgresql-9.1.2-1-osx.dmg
Installed pg gem.
Then when I executed rake db:create
getting the following error -
dlopen(/Users/sathishvc/.rvm/gems/ruby-1.9.3-head@knome-vivacious/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: /usr/local/lib/libpq.5.4.dylib
Checked if /usr/local/lib/libpq.5.4.dylib
exists or not. It does not.
So, it should be existing somewhere else in the system or I do not know, if I need to install any other piece of software for this.
Advice anyone please?
Try
brew prune
and then reinstallSome time after I posted this question, I found that
libpq.5.4.dylib
resides in/Library/PostgreSQL/9.1/lib/
.So, I created the following link:
lrwxr-xr-x 1 sathishvc admin 43 Jan 28 23:40 /usr/local/lib/libpq.5.4.dylib -> /Library/PostgreSQL/9.1/lib/libpq.5.4.dylib
.This solved the problem then.
if you have upgraded PostgreSQL with homebrew (brew update && brew upgrade), then simply uninstall the pg gem:
and the path will be corrected for you. No need to uninstall the whole PostgreSQL cluster.
In my case, uninstalling /reinstalling gem didn't help. But I added the PostgreSQL library path to
$DYLD_LIBRARY_PATH
environment variable in my~/.bash_profile
:If you also have MySQL installed, this line can look like:
Of course pay attention to version number in the PostgreSQL path, at the time of this writing it is 9.3. I'm using RVM, Ruby 2.0.0, pg gem 0.17.0, on Mac OS X 10.6.
I was running into this issue after switching over to the PostgresApp and removing the existing PostgreSQL version via
I ultimately solved the problem by re-installing PostgreSQL via
I was able to retain the use of the PostgresApp by adding the following to my .bash_profile
You can also try running:
As it alerted me to this as well as some additional errors.
This error was also affecting my ability to use the Paperclip gem as it was causing ImageMagick to fail with the same error.
(Using OS X 10.8.2)
this is not a direct answer to the question but can arise frequently
Two additional cases that might be of interest if you have upgraded PostgreSQL with homebrew:
you may actually have numerous versions of pg to rely upon
when you run
if you have more than one version, the system will ask which version you wish to delete. But that list may be useful to you! As an alternative to awenkhh's answer you may stop there and reset your gems to an acceptable version