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?
if you have upgraded
then simply uninstall the pg gem:
gem uninstall pg
bundle install
and the path will be corrected for you. No need to uninstall the whole PostgreSQL cluster.
I was running into this issue after switching over to the PostgresApp and removing the existing PostgreSQL version via
brew remove postgres
I ultimately solved the problem by re-installing PostgreSQL via
brew install postgres
I was able to retain the use of the PostgresApp by adding the following to my .bash_profile
export PATH="/Applications/Postgres.app/Contents/MacOS/bin:/usr/local/bin:$PATH"
You can also try running:
brew doctor
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)
I'm on OSX Monterey (M2-chipset) and had a similar issue. Running (mind the version) helped:
sudo ln -s /opt/homebrew/opt/postgresql@14/lib/postgresql@14/libpq.5.dylib /usr/local/lib/libpq.5.dylib
brew update, brew link --force, brew uninstall && brew install,.. all did not.
For me (MacOS Monterey) the file eventually turned up under: /usr/local/opt/postgresql@14/lib/postgresql@14/libpq.5.dylib
So to fix the initial error first create the directory it is looking for and then create a symlink to the existing file:
sudo mkdir -p /usr/local/opt/postgresql/lib/
sudo ln -s /usr/local/opt/postgresql@14/lib/postgresql@14/libpq.5.dylib /usr/local/opt/postgresql/lib/libpq.5.dylib
Try to run
bundle pristine pg
and that was it. you find solution here: https://github.com/Homebrew/homebrew-core/issues/109644
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