ruby-pg
ruby-pg copied to clipboard
PG Gem fails on Mac OS 11.x (Big Sur)
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
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.
Does this have any progress? Is this just a path issue or, as I'm assuming, a full rewrite?
Updating to the current pg 1.4.5 solves the issue for me
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.