Another active Homebrew process is already in progress

When I try to do this:

brew install node

I get this message:

 /usr/local/Homebrew/Library/Homebrew/utils/lock.sh: line 19: /usr/local/var/homebrew/locks/update: Permission denied
-e:1:in `initialize': Bad file descriptor (Errno::EBADF)
    from -e:1:in `new'
    from -e:1:in `<main>'
Error: Another active Homebrew process is already in progress.
Please wait for it to finish or terminate it to continue.
Error: Permission denied - /usr/local/var/homebrew/locks/node.brewing

Any idea on how to solve this?


Try removing the Homebrew process locks with this command:

rm -rf /usr/local/var/homebrew/locks

As this thread suggests at some point, my problem was to run brew command with sudo privileges for the first time. This causes brew to try to access privileged files and folders and it fails. If that's the case for you, run these commands and try installing node again.

sudo chown -R "$USER":admin /usr/local

brew cleanup


just close the terminal and reopen another


Simply type the following into your terminal:

brew cleanup

This should clean up any issues. Follow the command with:

brew doctor

All done.


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