1

I've encountered problem about brew services on postgresql@11 right now. After i reinstalled (from this blog) postgresql@11 it instantly gives an error on brew services. Then i ran this brew services restart -vvv postgresql@11 it returns this result:

<?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
   <plist version="1.0">
   <dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>homebrew.mxcl.postgresql@11</string>
    <key>ProgramArguments</key>
    <array>
        <string>~/.homebrew/opt/postgresql@11/bin/postgres</string>
        <string>-D</string>
        <string>~/.homebrew/var/postgresql@11</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>~/.homebrew/var/log/postgresql@11.log</string>
    <key>StandardOutPath</key>
    <string>~/.homebrew/var/log/postgresql@11.log</string>
    <key>WorkingDirectory</key>
    <string>~/.homebrew</string>
   </dict>
   </plist>

When i check the ~/.homebrew/var/log/postgresql@11.log file, it is empty. Also i check permissions on that file but it is ok(r,w). Still getting this error without any explanation(empty logs). 2 days ago it was working but somehow i broke it. Also i checked postmaster.pid but the file is not exist on my machine, i searched like this: find . -name "postmaster.pid"

Additionally, after i reinstalled postgresql@11 in my postgresql@11 directory (~/.homebrew/var/postgresql@11) is all empty.

Lastly, in my directory -> ~/.homebrew/Cellar/postgresql@11/11.13/bin there is postmaster file but it is not postmaster.pid file i dont know what is it for, but when i do ls -al it shows like this -> postmaster -> postgres

My machine is macOS Big Sur 11.5.2 on m1 chip macos. Hopefully someone gives me an idea about it.

What i realize right now is i have problem with installation as well. brew postinstall postgresql@11 as a result ->

Last 15 lines from ~/Library/Logs/Homebrew/postgresql@11/post_install.01.initdb:
2021-08-23 08:27:42 +0300

~/.homebrew/Cellar/postgresql@11/11.13/bin/initdb
--locale=C
-E
UTF-8
~.homebrew/var/postgresql@11

no data was returned by command ""~/.homebrew/Cellar/postgresql@11/11.13/bin/postgres" -V"
The program "postgres" is needed by initdb but was not found in the
same directory as "~/.homebrew/Cellar/postgresql@11/11.13/bin/initdb".
Check your installation.
Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall postgresql@11

However what i see is initdb and postgres in the same bin folder :/

Thanks,

Caner Taşan
  • 21
  • 1
  • 4

1 Answers1

0

Homebrew on M1 should be installed into /opt/homebrew. But from your output, ~/.homebrew but not /opt/homebrew is used as $HOMEBREW_PREFIX. What happened to your installation?

Homebrew doesn't support to be installed into arbitrary directory. Don't export $HOMEBREW_PREFIX to change it.


Quote from Homebrew FAQ

Why should I install Homebrew in the default location?

Homebrew’s pre-built binary packages (known as bottles) of many packages can only be used if you install in the default installation prefix, otherwise they have to be built from source. Building from source takes a long time, is prone to fail, and is not supported. Do yourself a favour and install to the default prefix so that you can use our pre-built binary packages. The default prefix is /usr/local for macOS on Intel, /opt/homebrew for macOS on Apple Silicon/ARM, and /home/linuxbrew/.linuxbrew for Linux. Pick another prefix at your peril!

Simba
  • 23,537
  • 7
  • 64
  • 76
  • This is because i export the path like that. The reason is, it will be more accesible. The below you can see my .zshrc file however i think this is not the case. @simba ```js function path { if [[ -d "$1" ]] ; then if [[ -z "$PATH" ]] ; then export PATH=$1 else export PATH=$PATH:$1 fi fi export PATH='' path ~/.homebrew/sbin path ~/.homebrew/bin path /usr/local/sbin path /usr/local/bin path /usr/sbin path /usr/bin path /sbin path /bin ``` – Caner Taşan Aug 23 '21 at 10:30
  • Also it works on other executables but in here it dies immediately. `postgres --version`-> output is -> `[1] 46094 killed postgres --version` `export HOMEBREW_PREFIX=~/.homebrew/` @Simba – Caner Taşan Aug 23 '21 at 10:37
  • @CanerTaşan What's the output when you start postgresql manually, with `~/.homebrew/opt/postgresql@11/bin/postgres -D ~/.homebrew/var/postgresql@11`? – Simba Aug 23 '21 at 10:39
  • It's same `~/.homebrew/opt/postgresql@11/bin/postgres -D ~/.homebrew/var/postgresql@11 [1] 47327 killed ~/.homebrew/opt/postgresql@11/bin/postgres -D ~/.homebrew/var/postgresql@11` @simba – Caner Taşan Aug 23 '21 at 10:45
  • Actually i reliase right now redis is running in `~/Library/LaunchAgents/homebrew.mxcl.redis.plist` however postgres try to run in here `~/.homebrew/opt/postgresql@11/homebrew.mxcl.postgresql@11.plist` @simba – Caner Taşan Aug 23 '21 at 10:47