When I try to do this:
brew install node
I get this message:
/usr/local/Homebrew/Library/Homebrew/utils/lock.sh: line 19:
just close the terminal and reopen another
In my case on OSX, I interrupted node install and then I try to start install node again so I got the error mentioned in the question.
I tried below steps from other responses:
sudo chown -R "$USER":admin /usr/local
brew cleanup
and
rm -rf /usr/local/var/homebrew/locks
but this message appear again - so don't know if above steps helped.
Then I closed the terminal tab and in new one ran
brew install -v node
It took 11 minutes to finish successfully node installation
If the above answer does not resolve your problem try removing the homebrew process locks with this command:
rm -rf /usr/local/var/homebrew/locks
I don't know what was going on. My only active terminal was waiting for input, no jobs running in the background. I had just tried to run an RVM install that failed and asked me to update Homebrew but that was supposed to be finished since the terminal was waiting for input. After several repeat command invocations and a couple of minutes later I stopped receiving the message.
This is on Mac OSX 10.13.6 with iTerm2.
⋊> brew --version
Homebrew 2.1.4
Homebrew/homebrew-core (git revision 97b15a; last commit 2019-06-07)
Homebrew/homebrew-cask (git revision 2a010; last commit 2019-06-07)
Change file permission will avoid this error:
sudo chown <your-username>:admin /usr/local/Homebrew/Library/Homebrew/utils/lock.sh
For permission issues with homebrew install or update:
Change your homebrew permission setting
sudo chown -R <your-username>:admin /usr/local/Homebrew
sudo chown -R <your-username>:admin /usr/local/var/homebrew
Then run homebrew install or update
Simply type the following into your terminal:
brew cleanup
This should clean up any issues. Follow the command with:
brew doctor
All done.