4

When installing PostgreSQL via Homebrew on Mac (OSX 10.11.6) I get the following errors:

Error: The `brew link` step did not complete successfully The formula
  built, but is not symlinked into /usr/local

and

initdb: file "/usr/local/share/postgresql/postgres.bki" does not exist
  This might mean you have a corrupted installation or identified the 
  wrong directory with the invocation option -L.

The /postgresql folder doesn't exist.

Not sure if it's relevant, but I already have OpenSSL 1.0.2o_2 and Readline 7.0.5 installed via Homebrew.

Does anyone know why this error occurs and how I can solve it?

6
  • Had some trouble also with Postgres installing with Homebrew. Found postgresapp.com for managing different PostgreSQL versions on OSX Commented Aug 1, 2018 at 11:31
  • Thanks for the tip, struggling to find a solution to this. Will probably try that instead! Commented Aug 1, 2018 at 11:39
  • Have you had a look at the output of brew doctor? Maybe it could give you a clue. Also, could you show how exactly you install PostgreSQL via Homebrew? Commented Aug 1, 2018 at 11:49
  • 1
    The directory /usr/local/share/postgresql should contain all the symlinks to the relevant files installed by Homebrew after a successful installation. So, I guess, the question is why this directory and the symlinks do not get created in your case. I just did brew reinstall postgresql on my machine and it works fine. Did you maybe manually change the permissions of /usr/local/share? Commented Aug 1, 2018 at 11:58
  • Thanks anothernode. You're right, it was a permissions issue. Recursively sudo chowning the /user/local/share folder did the trick. Commented Aug 1, 2018 at 12:04

2 Answers 2

14

In my case, I had installed libpq which prevented postgresql from linking. Unlinking libpq followed by linking postgresql fixed the issue for me.

brew unlink libpq
brew link postgresql
brew postinstall postgresql
Sign up to request clarification or add additional context in comments.

2 Comments

this is the same case for me
This reply deserves a medal🥇
0

Managed to solve the problem. It's a permissions issue. The original answer can be found here: Homebrew: Could not symlink, /usr/local/bin is not writable

In short, perform the following commands:

sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
sudo chown -R `whoami`:admin /usr/local/opt

1 Comment

This din't work for me. Still getting the same error.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.