Today I Learned

A Zero One initiative

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

If after installing pg gem in your ruby project and you get the following error with the pg gem

Library not loaded: libpq.5.dylib

You can fix the linking issues by running the following commands:

cd ~/[your ruby path]/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

You may need to modify the commands above to suite your ruby manager and currently installed versions.

Looking for help? Each developer at Zero One has years of experience working with Ruby applications of all types and sizes. We're an active presence at Ruby conferences, and have worked on many of the web's Ruby on Rails success stories. Contact us today to talk about your Ruby project.