Brew cleanup Error: Permission denied @ unlink_internal

24,687

Solution 1

First fix permissions causing the error:

sudo chown -R "$(whoami)":admin /usr/local

On macOS Mojave, the chown command needs to be run on the specific directory, an example for the permissions issue in /usr/local/lib directory, this command would be

sudo chown -R "$(whoami)":admin /usr/local/lib

Then relink node with the --force option as directed:

brew link --overwrite node

Solution 2

This worked for me:

brew unlink node && brew link node
Share:
24,687
SoftTimur
Author by

SoftTimur

Updated on May 18, 2020

Comments

  • SoftTimur
    SoftTimur about 4 years

    I met an error while doing "brew cleanup":

    $ brew cleanup
    Warning: Skipping opam: most recent version 2.0.3 not installed
    Warning: Skipping python: most recent version 3.7.2_2 not installed
    Warning: Skipping sqlite: most recent version 3.27.1 not installed
    Error: Permission denied @ unlink_internal - /usr/local/lib/node_modules/@angular/cli/node_modules/.bin/in-install
    

    Does anyone know how to fix this?

    PS: brew link node returns an error, though I don't know if it is related.

    $ brew install node
    Warning: node 11.9.0 is already installed, it's just not linked
    You can use `brew link node` to link this version.
    $ brew link node
    Linking /usr/local/Cellar/node/11.9.0... 
    Error: Could not symlink include/node/common.gypi
    Target /usr/local/include/node/common.gypi
    already exists. You may want to remove it:
      rm '/usr/local/include/node/common.gypi'
    
    To force the link and overwrite all conflicting files:
      brew link --overwrite node
    
    To list all files that would be deleted:
      brew link --overwrite --dry-run node