0

Somehow permissions have been altered on brew and/or pip3 and both are getting errors.

brew has a lock file but when I remove it with sudo, brew commands say it iw still there. pip3 worked to install mat, but it told me I should update pip3. However, running the command it said to use gets a permissions error.

I would think that restoring from Time Machine would fix it, but I'm not quite sure what directories to restore. I don't want to 'restore' something else that was legitimately changed.

Update: brew gives a different message after reboot:

WGroleau@MBP ~ % brew update
/usr/local/Homebrew/Library/Homebrew/utils/lock.sh: line 29: /usr/local/var/homebrew/locks/update: Permission denied
Traceback (most recent call last):
    2: from -e:1:in `<main>'
    1: from -e:1:in `new'
-e:1:in `initialize': Bad file descriptor (Errno::EBADF)
Error: Another active Homebrew update process is already in progress.
Please wait for it to finish or terminate it to continue.

before, it was almost the same, but it also gave the path/name of a lock file, which I deleted, only to find a retry complained about the same file.

I did NOT run another home-brew process in parallel.

I examined the script mentioned above. Line 29 was not helpful, but a different part of the script had an error message about permissions and suggested sudo chown -R \$(whoami):staff /usr/local/var/homebrew which enabled brew to START running and do a lot, but then started complaining "no such file" in the "Cellar" and also mentioning symlinks. So I tried sudo chown -R \$(whoami):staff /usr/local/Cellar /usr/local\Homebrew /usr/local\Frameworks and that allowed brew upgrade to run a lot further. But I still got "Error: Permission denied @ apply2files - /usr/local/share/locale/am/LC_MESSAGES/glib20.mo".

Perhaps brew can only be run by the account that installed it … yes (sigh)

3
  • What are the exact errors and command line used?
    – mmmmmm
    Commented Sep 18, 2021 at 18:52
  • You can find and restore the exact files of brew and pip3 and brew via time machine with the commands “which brew” and “which pip3”. These will each return a path of an executable that time machine can restore. In finder, press shift + command + . to display the hidden and/or system files and folders that the utilities are located in Commented Sep 18, 2021 at 20:02
  • I think it's more than just the two executables. But maybe the entire /usr/local Anything else would be risky, as I updated to OS 11.6 since the last backup.
    – WGroleau
    Commented Sep 18, 2021 at 20:33

1 Answer 1

1

brew should only be run by the account that installed it.

But first, I have to reverse the chown commands I ran under a different account with

sudo chown -R $(whoami):staff /usr/local/var/homebrew \
                              /usr/local/Homebrew \
                              /usr/local/Cellar \
                              /usr/local/Frameworks

Then brew upgrade ran without error in that account.

4
  • There is a reason /usr/local should be updated by root and not an individual user :)
    – mmmmmm
    Commented Sep 18, 2021 at 22:31
  • A command similar to that is what brew requested when it was getting errors. It works now.
    – WGroleau
    Commented Sep 19, 2021 at 0:09
  • @mmmmmm Homebrew thinks it's a feature that they trash /usr/local. Commented Sep 19, 2021 at 13:17
  • /usr/local was updated by root (sudo). Only the subdirs installed by home-brew are owned by the installing account.
    – WGroleau
    Commented Sep 19, 2021 at 21:46

You must log in to answer this question.

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