93

I'm trying to install Node.js with Homebrew (I installed it previously without using brew, and I've tried deleting all of those files). I've looked at previous questions asking similar things, but I haven't been able to get them to work. First I tried brew link node which gave me:

myusername@c126h060:~$ brew link node
Linking /usr/local/Cellar/node/0.12.6... 
Error: Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
  rm '/usr/local/share/systemtap/tapset/node.stp'

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

And then when I run brew link --overwrite node I get the following:

myusername@c126h060:~$ brew link --overwrite node
Linking /usr/local/Cellar/node/0.12.6... 
Error: Could not symlink share/systemtap/tapset/node.stp
/usr/local/share/systemtap/tapset is not writable.

Additionally, when I tried using brew link -n node to find files to manually delete, I managed to delete some of them, but I'm still left with the following files that I can't delete:

myusername@c126h060:~$ brew link -n node
Would link:
/usr/local/etc/bash_completion.d/npm
/usr/local/bin/node
/usr/local/include/node
/usr/local/share/man/man1/node.1
/usr/local/share/systemtap/tapset/node.stp
/usr/local/lib/dtrace/node.d

When I try to delete I get the following (same thing for all of these files):

myusername@c126h060:~$ rm /usr/local/etc/bash_completion.d/npm
rm: /usr/local/etc/bash_completion.d/npm: No such file or directory

What should I do?

mlinegar
  • 1,389
  • 1
  • 11
  • 19

8 Answers8

175

It may be that you don't actually own your systemtap directory. Navigate to /usr/local/share and run this command in order to make yourself the owner:

chown -R <yourusername>:<yourgroupname> systemtap

When I was fixing this same issue earlier today, I had to also go into /usr/local and do the same thing for the lib directory.

Darryl Hein
  • 142,451
  • 95
  • 218
  • 261
verbranden
  • 1,766
  • 1
  • 12
  • 8
  • 10
    do not forgot about "sudo". sudo chown -R : systemtap – 1nstinct Oct 14 '15 at 14:05
  • 2
    I am getting systemtap: "No such file or directory". I am using macOS sierra. – lmc Dec 10 '16 at 10:05
  • 3
    hmm, giving the complete path, /usr/local/share/systemtap/ worked – lmc Dec 10 '16 at 10:07
  • 2
    can someone give an example of the chow line without the placeholders? I don't want to input the wrong things. thanks in advance – Vash Jun 08 '18 at 19:36
  • 3
    ```sudo chown -R victor:admin systemtap``` perfectly worked for me !! Successfully upgraded my node to v14.8.0 :) – Victor Aug 22 '20 at 11:02
26

get your username,

and get your groups:(could be more than one,generally is 'admin')

whoami
groups

then, for exapmle:

sudo chown -R chrislee:admin /usr/local/share/systemtap/
coderChrisLee
  • 289
  • 3
  • 6
23

Or, alternatively, verify the ownership and permissions on systemtap

$ ls -al /usr/local/share/systemtap/
drwxr-xr-x   3 root  wheel  102 Oct 23 18:06 .
drwxrwxr-x  15 root  wheel  510 Oct 24 20:24 ..
drwxr-xr-x   2 root  wheel   68 Oct 24 20:17 tapset

then add yourself to the owner group (in this case wheel)

sudo dscl . append /Groups/wheel GroupMembership <username>

then change the permissions on tapset to allow group edits

sudo chmod -R 775 /usr/local/share/systemtap/tapset/
cluther
  • 421
  • 3
  • 10
23

What worked for me:

  1. cd /usr/local/share
  2. sudo chown -R <user>:<group> systemtap (Did 1 & 2 for /usr/local too)

Above steps were failing. Went to next answer. Tried;

ls -al /usr/local/share/systemtap/ which throwed a 'Not found error.'

Then: brew link node was throwing an error. So I did:

  1. sudo rm -rf /usr/local/lib/node_modules
  2. brew postinstall node -v
  3. And at last brew link node
  4. node -v :)

So basically I removed all node_modules/ folders and redid everything.

Asim K T
  • 16,864
  • 10
  • 77
  • 99
12
arun:~$ brew link node
Linking /usr/local/Cellar/node/0.12.6... 
Error: Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
  rm '/usr/local/share/systemtap/tapset/node.stp'

Run below commands

brew postinstall node -v
brew link node 
Caleb Kleveter
  • 11,170
  • 8
  • 62
  • 92
arunkumar sambu
  • 653
  • 1
  • 9
  • 22
3

The following recipe worked for me:

  1. Add your username to add group wheel sudo dscl . append /Groups/wheel GroupMembership username
  2. sudo chmod -R 775 /usr/local/share/systemtap/tapset/
  3. sudo rm -rf /usr/local/lib/node_modules
  4. brew cleanup
  5. brew link node
  6. brew uninstall --force node
  7. brew install node

Then check version with node -v and npm -v.

B--rian
  • 5,578
  • 10
  • 38
  • 89
Shamsher
  • 31
  • 1
  • 2
    Welcome to SO! Please keep in mind the guidelines at https://stackoverflow.com/help/how-to-answer and edit your post accordingly, e.g. by adding more explanation why your solution worked. – B--rian Sep 05 '19 at 13:51
  • These steps worked perfectly for me. Thanks a lot – Hicham Dec 05 '21 at 20:27
1

This command was the answer for the error message for me. It changes the folder permissions to the current user:

sudo chown -R $(whoami) /usr/local/share/systemtap
reinierkors
  • 507
  • 6
  • 19
0

just add sudo in the beginning of the command npm install expo-cli --global

like sudo npm install expo-cli --global and hit enter.

hope it'll help you.

Raghib Arshi
  • 717
  • 8
  • 12