ruby-pg icon indicating copy to clipboard operation
ruby-pg copied to clipboard

PG Gem fails on Mac OS 11.x (Big Sur)

Open portwood opened this issue 5 years ago • 2 comments
trafficstars

When I run 'rake about' or 'rails s', I receive the following error: LoadError: Error loading the 'postgresql' Active Record adapter. Missing a gem it depends on? dlopen(/Users/mp/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib

I've successfully recompiled it using the latest development tools without errors, but the error persists when I launch rails.

Additional details: Ruby 2.7.2 Rails 6.0.3.4 Pg 1.2.3 PostgreSQL version: 11.5 Prior OS version 10.15.7 (works fine) Current OS version 11.0.1 and 11.1 (fails) Hardware: Intel i7 How I install the gem: sudo gem install pg -- --with-pg-config=/Library/PostgreSQL/11/bin/pg_config

No issues running PostgreSQL on 11.0.1 or 11.1

portwood avatar Nov 13 '20 13:11 portwood

Running this in the command line solves the problem on my machine:

cd /Users/mp/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib
install_name_tool -change libpq.5.dylib /Library/PostgreSQL/12/lib/libpq.5.12.dylib pg_ext.bundle

Essentially, changes the expected/default dynamic library path in the gem.

toncid avatar Feb 05 '21 14:02 toncid

Does this have any progress? Is this just a path issue or, as I'm assuming, a full rewrite?

daBee avatar Mar 09 '21 17:03 daBee

Updating to the current pg 1.4.5 solves the issue for me

MattBudz avatar Dec 21 '22 12:12 MattBudz

pg-1.3.0 introduced support for pkg-config, that might help installing pg on Macos. On the other hand new ruby versions might have fixed build issues, so that I'll close this old topic now.

larskanis avatar Feb 25 '23 16:02 larskanis