3

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?

memoht
  • 781
  • 5
  • 17

2 Answers2

6

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.

Community
  • 1
  • 1
stephenalexbrowne
  • 1,191
  • 2
  • 10
  • 22
  • Hey now, I think you have just shed some light on my issue. I got so tangled up in my problem, I totally spaced checking the Github repo for this app. Thanks for the suggestion. I now see this problem is documented and hopefully they will get a fix in place. Thank you! – memoht May 24 '13 at 18:01
  • I think you may have trouble passing flags or piping to your psql command if aliased like this. Sometimes you want to do something like psql db < db.sql – Anatortoise House Jun 13 '13 at 18:26
  • Of course it's not a perfect solution. Just a workaround. From the issues page, it seems that downgrading Postgres.app also works. – stephenalexbrowne Jun 14 '13 at 18:43
1

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..)
catsby
  • 11,276
  • 3
  • 37
  • 37