문제

I just upgraded my Postgres.app to latest version (9.2.4.1) am now unable to start my Rails app using Foreman or Rails server.

/Users/memoht/Sites/myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg.rb:4:in `require': dlopen(/Users/memoht/Sites/myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg_ext.bundle, 9): Library not loaded: @executable_path/../lib/libssl.1.0.0.dylib (LoadError)

Referenced from: /Applications/Postgres.app/Contents/MacOS/lib/libpq.dylib

Reason: image not found - /Users/memoht/Sites/myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg_ext.bundle


  • Looked through Postgres.app documentation

  • Upgrade from 9.2.2.0 to 9.2.4.1 isn't a new minor release so shouldn't involve pg_upgrade

  • .bashrc has correct setting for PATH PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

  • Uninstalled, and reinstalled PG gem.

  • Made the mistake of thinking I needed to install PostGIS via homebrew, but that automatically installed Postgres via Brew plus a slew of other dependencies.

If I swap out the Postgres.app version back down to 9.2.2.0 everything works again. Since Postgres.app is a drag and drop install, why has upgrading from 9.2.2.0 to 9.2.4.1 caused this?

도움이 되었습니까?

해결책

I found a solution that works for me and requires minimal hacking/configuring. You only need to do this once and it will work for every bundle install. Add the following to your .bash_profile, .bash_rc, or equivalent:

export DYLD_FALLBACK_LIBRARY_PATH=/Applications/Postgres.app/Contents/MacOS/lib:$DYLD_LIBRARY_PATH

(Assuming you installed Postgres.app in the default location). Then restart your terminal session and try again.

Exporting to DYLD_LIBRARY_PATH directly can cause serious problems with other apps that depend on it, but using the fallback path avoids these problems.

See also:

EDIT: It seems that setting DYLD_FALLBACK_LIBRARY_PATH causes an error when you try to run psql. To fix this, you can add the following two lines to your .bash_profile:

alias psql="(. ~/.bash_profile; unset DYLD_FALLBACK_LIBRARY_PATH; psql)";

This is assuming that you're using bash and that your .bash_profile is located in your home directory. If that's not the case (or if you're using a .bashrc or other environment setup instead of .bash_profile) change the ~/.bash_profile part of the command to the path to your environment setup script.

The aliased commands basically start a subshell which does not effect your current bash environment. So when it unsets the DYLD_FALLBACK_LIBRARY_PATH variable, it's only temporary. After you exit psql the environment variable will be set again so that rails functions properly.

다른 팁

It's likely your pg gem in your app was built against the old libraries. Try rebuilding it against the new Postgres.app:

$ gem uninstall pg
[...]
$ bundle install
[...]
"installing pg" (or something..)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top