If You are working on MacBook with M1 processor and getting this error or similiar:

(no such file), '/usr/lib/libpq.5.dylib'

Try uninstalling all instances of pg gem and reinstalling it with:

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config

That's it for this post, thanks for reading!