9

I have a script I use for maintaining by Homebrew installation containing the line

brew --config && echo;  brew update && echo; brew upgrade && brew list && echo; brew leaves && echo; brew cask list && echo; 

and running (typically) in ~. Occasionally when I run this script I get output that includes

Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.

followed by

Error: Another active Homebrew update process is already in progress.
Please wait for it to finish or terminate it to continue.

How do I prevent this from happening?

From reading the suggested help, I expect that running something like git gc --auto --aggressive && explicitly first would work, but it's unclear to me how to aim it at the right repo. Or is the cause something else entirely?

orome
  • 45,163
  • 57
  • 202
  • 418

1 Answers1

11

The active homebrew is usually from a lock file being stuck... you could try rm /usr/local/var/homebrew/locks/* in script before the error or find specific offending lock and remove it. Also, you can find what is failing to remove it and why but more info would be needed. If something is running on another thread it's possible there is some race condition.

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
Aslan Varoqua
  • 191
  • 1
  • 6
  • Actually all I need to do is spot that message and wait a bit, so the question is really how to do that. – orome Sep 22 '17 at 12:03