Pure: Failed to create symbolic link

Created on 1 Dec 2015  Â·  12Comments  Â·  Source: sindresorhus/pure

When i install pure, i get this error message:

❯ sudo npm install --global pure-prompt
|
> [email protected] postinstall /usr/local/lib/node_modules/pure-prompt
> dest=/usr/local/share/zsh/site-functions/; mkdir -p $dest && ln -sf "$PWD/pure.zsh" $dest/prompt_pure_setup && ln -sf "$PWD/async.zsh" $dest/async || echo 'Could not automagically symlink the prompt. Check out the readme on how to do it manually: https://github.com/sindresorhus/pure#manually'

ln: failed to create symbolic link ‘/usr/local/share/zsh/site-functions//prompt_pure_setup’: Permission denied
Could not automagically symlink the prompt. Check out the readme on how to do it manually: https://github.com/sindresorhus/pure#manually
[email protected] /usr/local/lib/node_modules/pure-prompt

I know i can simply follow manual instruction. But i just wonder why the automagic method does not work.

I am using Xubuntu 15.10

Most helpful comment

Well, this is working perfectly. I wonder why automatic install script point the script to double slash path, which is invalid.

Great, then I think @veggiemonk's PR should fix this issue!


A little bit OT, i can't install anything outside my home directory without sudo (including /usr/local). Am i missing some typical configuration?

That's usually how it is, sometimes people give their user access to /usr/local by changing the permissions. Another option (in the case of npm) is to e.g. use nvm to manage node versions (you can follow this guide), or in the case of OS X install through homebrew.

All 12 comments

what's the output of ls -ld /usr/local/share/zsh/site-functions/?

Here it is.

❯ ls -ld /usr/local/share/zsh/site-functions/
drwxrwsr-x 2 root staff 4096 Des  1 12:30 /usr/local/share/zsh/site-functions/

First off, I'd recommend avoiding running npm as root. What if we at some point decided to just let the world burn and change the install script to rm -rf /, you wouldn't be having a great time at that point :smile:

I'm thinking that maybe the problem in your case is the double slash ...//prompt_pure_setup. Can't think of any other reason the symlink might be failing.

PR #177 that removes the trailing /

@mafredri I know this is off-topic but it is a pet peeve of mine so here it is :)

First off, I'd recommend avoiding running npm as root. What if we at some point decided to just let the world burn and change the install script to rm -rf /, you wouldn't be having a great time at that point

If you at some point decided to change the install script to rm -rf ~ you would cause me exactly the same grief as rm -rf /, and not running as root doesn’t help me there. To most users ~ is much more valuable than what’s outside of it.

I agree not using root is good, just not with the reasoning.

If you at some point decided to change the install script to rm -rf ~ you would cause me exactly the same grief as rm -rf /, and not running as root doesn’t help me there. To most users ~ is much more valuable than what’s outside of it.

I agree not using root is good, just not with the reasoning.

@micampe I'm not quite sure what kind of reasoning you're looking for, I just gave it as an example. And be that as it may, a rm -rf / is definitely more devastating than a rm -rf ~. With the latter, you lose all your files, but with the former you have a system that will not boot and is unfixable without external aids.

We could argue forever about this, but I doubt I'll be convinced that running stuff as root from an untrusted source is ever a good idea. Even worse than having your system deleted is that you could have rootkits and spyware installed, but I digress.

I doubt I'll be convinced that running stuff as root from an untrusted source is ever a good idea.

That is not what I meant, but as I said this is off-topic so I don’t think it’s interesting for other people following pure.

That is not what I meant, but as I said this is off-topic so I don’t think it’s interesting for other people following pure.

Yeah, I guess not, my bad for putting it that way :).


So back on topic: @mufid would you mind testing what happens if you run

cd /usr/local/lib/node_modules/pure-prompt
sudo ln -sf "$PWD/pure.zsh" /usr/local/share/zsh/site-functions//prompt_pure_setup
sudo ln -sf "$PWD/async.zsh" /usr/local/share/zsh/site-functions//async

compared to

cd /usr/local/lib/node_modules/pure-prompt
sudo ln -sf "$PWD/pure.zsh" /usr/local/share/zsh/site-functions/prompt_pure_setup
sudo ln -sf "$PWD/async.zsh" /usr/local/share/zsh/site-functions/async

?

cd /usr/local/lib/node_modules/pure-prompt
sudo ln -sf "$PWD/pure.zsh" /usr/local/share/zsh/site-functions/prompt_pure_setup
sudo ln -sf "$PWD/async.zsh" /usr/local/share/zsh/site-functions/async

Well, this is working perfectly. I wonder why automatic install script point the script to double slash path, which is invalid.


A little bit OT, i can't install anything outside my home directory without sudo (including /usr/local). Am i missing some typical configuration?

Well, this is working perfectly. I wonder why automatic install script point the script to double slash path, which is invalid.

Great, then I think @veggiemonk's PR should fix this issue!


A little bit OT, i can't install anything outside my home directory without sudo (including /usr/local). Am i missing some typical configuration?

That's usually how it is, sometimes people give their user access to /usr/local by changing the permissions. Another option (in the case of npm) is to e.g. use nvm to manage node versions (you can follow this guide), or in the case of OS X install through homebrew.

Cool. Thanks

Another option is to just change your prefix config to a folder under your ownership, see https://docs.npmjs.com/files/npmrc and https://docs.npmjs.com/files/folders#prefix-configuration. I use nvm just out of habit but if your system's node version is kept up to date, and you don't need multiple versions of node, you don't need nvm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ELLIOTTCABLE picture ELLIOTTCABLE  Â·  11Comments

hyphaene picture hyphaene  Â·  9Comments

sudo-nice picture sudo-nice  Â·  6Comments

opticalgenesis picture opticalgenesis  Â·  9Comments

harukizaemon picture harukizaemon  Â·  10Comments