Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Brew cleanup Error: Permission denied @ unlink_internal

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
like image 640
SoftTimur Avatar asked Feb 14 '19 03:02

SoftTimur


Video Answer


2 Answers

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
like image 61
hmedia1 Avatar answered Sep 28 '22 02:09

hmedia1


This worked for me:

brew unlink node && brew link node
like image 26
Shrolox Avatar answered Sep 28 '22 00:09

Shrolox