Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg_ctl and psql not found after installing postgresql@16 #176587

Closed
2 of 3 tasks
nbro opened this issue Jul 6, 2024 · 5 comments
Closed
2 of 3 tasks

pg_ctl and psql not found after installing postgresql@16 #176587

nbro opened this issue Jul 6, 2024 · 5 comments
Labels
bug Reproducible Homebrew/homebrew-core bug

Comments

@nbro
Copy link

nbro commented Jul 6, 2024

brew doctor output

Your system is ready to brew.

Verification

  • My "brew doctor output" above says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update twice and am still able to reproduce my issue.
  • This issue's title and/or description do not reference a single formula e.g. brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.

brew config output

HOMEBREW_VERSION: 4.3.8
ORIGIN: https://github.com/Homebrew/brew
HEAD: e5f776b3e23cae8f1b6c3d1194b8329bf701965f
Last commit: 6 days ago
Core tap JSON: 06 Jul 22:10 UTC
Core cask tap JSON: 06 Jul 22:10 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 3.3.3 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.3/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 15.0.0 build 1500
Git: 2.39.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.6.0 => /usr/bin/curl
macOS: 14.5-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: N/A
Rosetta 2: false

What were you trying to do (and why)?

I tried to install PostgreSQL 16 using brew install postgresql@16.

brew services list --all shows now it's running after brew services start postgresql@16.

Now, I was expecting to be able to check the server status with pg_ctl too, for example, using the command pg_ctl status -D /opt/homebrew/var/postgresql@16, but I'm getting the following error zsh: command not found: pg_ctl

The following command psql -l also returns zsh: command not found: psql

As opposed to Homebrew/brew#17288, now, I really have the data cluster at /opt/homebrew/var/postgresql@16, though

PG_VERSION
base
global
pg_commit_ts
pg_dynshmem
pg_hba.conf
pg_ident.conf
pg_logical
pg_multixact
pg_notify
pg_replslot
pg_serial
pg_snapshots
pg_stat
pg_stat_tmp
pg_subtrans
pg_tblspc
pg_twophase
pg_wal
pg_xact
postgresql.auto.conf
postgresql.conf
postmaster.opts
postmaster.pid 

Apparently, these binaries should be at /opt/homebrew/Cellar/postgresql@16/16.3/bin/, but they were not added to the path. Shouldn't they be added automatically?

So, the workaround so far is to add something like export PATH="/opt/homebrew/Cellar/postgresql@16/16.3/bin:$PATH" to my ~/.bashrc or ~/.zshrc, but shouldn't this be done automatically?

I see only only one problem with this approach, i.e. if you want to install multiple postgresql versions. However, after installing postgresql, we should at least get a message that tells us how to add this directory to the path and check if our shell configuration files already export some of these directories from other potential brew installations

What happened (include all command output)?

Please, see above

What did you expect to happen?

Please, see above

Step-by-step reproduction instructions (by running brew commands)

Please, see above
@nbro nbro added the bug Reproducible Homebrew/homebrew-core bug label Jul 6, 2024
@ZhongRuoyu ZhongRuoyu transferred this issue from Homebrew/brew Jul 7, 2024
@ZhongRuoyu
Copy link
Member

This issue's title and/or description do not reference a single formula e.g. brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.

They do.


Please have a look at the caveats in output of brew info postgresql@16; they should also have been shown to you at the end of brew install. The keg-only status of postgresql@16 means the executables are not added to PATH. To make them visible, add export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH" to your shell profile like ~/.zshrc.

@ZhongRuoyu ZhongRuoyu closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2024
@MikeMcQuaid
Copy link
Member

@nbro Don't 👎🏻 people who have spent their time explaining the answer to your problem. It's not polite.

@nbro
Copy link
Author

nbro commented Jul 12, 2024

I was already providing a workaround to the problem. The user just closed the issue as if this was not an issue. In my view, this is still an issue. If you install a specific version of PostgreSQL and there's no other version, then the associated binaries should be automatically added to the PATH. If there's already another version, then I agree that they should not be added to the PATH. In any case, brew should do these checks. You can definitely check if there's already another PostgreSQL version installed with brew.

@lgrosz
Copy link

lgrosz commented Aug 18, 2024

I'm new to PostgreSQL and quite unaware when it comes to Homebrew installations, but why would postgresql@14 be linked poured (? not sure if I'm using the lingo right) but newer versions like @15 and @16 not be? I understand from brew info that they aren't poured linked because @14 is, but why when there are newer versions available?

@gromgit
Copy link
Member

gromgit commented Aug 18, 2024

Because postgresql@14 was renamed from plain postgresql, which (as you might have guessed) was not keg-only, hence linked. This will remain so until v14 is removed as part of Homebrew's standard EOL handling, at which point no PostgreSQL formula will be linked: #167593 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible Homebrew/homebrew-core bug
Projects
None yet
Development

No branches or pull requests

5 participants