I'm trying to fix a path-related problem with glib, but as part of this another problem has appeared:

brew install pkg-config
Warning: pkg-config 0.29.2 is already installed and up-to-date

Ok, good, so:

pkg-config --cflags glib-2.0
-bash: /usr/local/bin/pkg-config: Permission denied

Right, right...

sudo pkg-config --cflags glib-2.0
sudo: pkg-config: command not found

Does anyone know what's going on here?

Update: one of the commands fixed things:

pkg-config --cflags glib-2.0
-I/usr/local/Cellar/glib/2.62.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.62.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.43/include
  • 3
    Adding the output of ls -l /usr/local/bin/pkg-config and (assuming it's a symlink) the link target might help. Also running brew doctor (and resolving any issues) or brew reinstall pkg-config should fix a lot of potential issues. – nohillside Nov 26 '19 at 12:31

I wouldn’t sudo anything brew related for installs in /usr/local and use one Unix user only to manage homebrew. The only exception is some initial setup or remediation steps when you are explicitly instructed by the tool to use sudo

What’s happening is some permissions (using sudo likely) went bad in /usr/local so you might need to revert them.

brew doctor

The above command is designed to find and help you fix many of the common ways people can have issues installing packages so I would start there. Also run a command to see what leaves you need in case you have to clean up and remove all the brewed items and reinstall one by one once your permissions are set.

brew leaves
  • 1
    One of the commands here appears to have fixed it. Updated – Maury Markowitz Nov 26 '19 at 12:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .