Greg Rogers
Greg Rogers

Reputation: 1031

Broken Rails setup / pg gem

UGH... I broke my (formerly functioning) Rails setup - under OS X Yosemite. I did so using Homebrew to update my version of Git. After getting Git where I want it, running 'rails c' gives these errors:

/Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg.rb:4:in `require': dlopen(/Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg_ext.bundle, 9): Library not loaded: /usr/local/lib/libpq.5.6.dylib (LoadError)
  Referenced from: /Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg_ext.bundle
  Reason: image not found - /Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg_ext.bundle

Seeing the reference to pg_ext, I tried to verify pieces of my postgresql installation. If I try 'gem install pg' or try to update the gem with bundler, I get this:

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /Users/grogers/.rbenv/versions/2.0.0-p353/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

I'm probably making my problem worse, but I went back and redid a 'brew install postgres' but still get the same error.

Any help appreciated. Thank you!

Upvotes: 1

Views: 603

Answers (1)

stevenharman
stevenharman

Reputation: 508

Did you also upgrade Postgresql via Homebrew? If not, what version of Postgres are you running, and how do you install it?

If you did upgrade your Postgres you'll need to rebuild the native bindings for the pg gem: gem uninstall pg && gem install pg.

Upvotes: 3

Related Questions