homebrew installation confused matters when rails accessing postgresql

Viewed 41

Needing access to ffmpeg that was installed on OS X Monterey. The stream of items was such that I missed anything related to postgresql.

Now, rails or rake commands will not start

 dlopen(/Users/deploy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.4.1/lib/pg_ext.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/postgresql/lib/libpq.5.dylib (LoadError)
  Referenced from: /Users/deploy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.4.1/lib/pg_ext.bundle
  Reason: tried: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file), '/opt/homebrew/Cellar/postgresql@14/14.5_4/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file) - /Users/deploy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.4.1/lib/pg_ext.bundle

command brew reinstall libpq interrupts because

libpq is keg-only, which means it was not symlinked into /opt/homebrew,
because conflicts with postgres formula.

To which homebrew suggests

To reinstall 14.5_4, run:
  brew reinstall postgresql@14

as that runs

You can migrate to a versioned data directory by running:
  mv -v "/opt/homebrew/var/postgres" "/opt/homebrew/var/postgresql@14"
[...]
This formula has created a default database cluster with:
  initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@14
For more details, read:
  https://www.postgresql.org/docs/14/app-initdb.html

To restart postgresql@14 after an upgrade:
  brew services restart postgresql@14

postgres@14 does restart Successfully started postgresql@14 (label: homebrew.mxcl.postgresql@14) but rails commands return the same error as above.

Now, possibly, the directories could have lost the exisitn databases? as /opt/homebrew/opt has

lrwxr-xr-x    1 deploy  admin    30 Sep 21 16:12 postgresql -> ../Cellar/postgresql@14/14.5_4
lrwxr-xr-x    1 deploy  admin    30 Sep 21 16:12 postgresql@14 -> ../Cellar/postgresql@14/14.5_4

And it appears the structure of the files enter image description here does confirm that postgresql/lib/libpq.5.dylib does not exist by adding another directory in the midst.

Uninstalling and re-installing postgresql does not change this behaviour, so while psql can be invoked, rails cannot connect.

How does one get out of this loop?

0 Answers
Related