lukechilds / zsh-nvm

Zsh plugin for installing, updating and loading nvm
MIT License
2.24k stars 113 forks source link

Permission denied when trying to install the plugin #14

Closed dmitriz closed 7 years ago

dmitriz commented 7 years ago

Trying to follow the installation instructions https://github.com/lukechilds/zsh-nvm#as-an-oh-my-zsh-custom-plugin and added to .zshrc:

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
plugins+=(zsh-nvm)
...
source $ZSH/oh-my-zsh.sh
...

but still getting the error

source .zshrc   
Installing nvm...
fatal: could not create leading directories of '/Users/dmitrizaitsev/.nvm': Permission denied
_zsh_nvm_install:cd:3: no such file or directory: /Users/dmitrizaitsev/.nvm

Any help?

lukechilds commented 7 years ago

Sorry traveling atm, so might not be that responsive.

Do you already have nvm installed?

dmitriz commented 7 years ago

I have managed to install with homebrew.

lukechilds commented 7 years ago

Homebrew installation isn't officially supported by nvm.

Happy to help you get this resolved if you're still interested.

dmitriz commented 7 years ago

I surely would be interested what was the problem with the supported installation ;)

lukechilds commented 7 years ago

It appears to be an issue with git not having permission to create the /Users/dmitrizaitsev/.nvm folder to clone nvm into. Weird question but did the session you ran source .zshrc from definitely have write access to your home folder?

dmitriz commented 7 years ago

I suppose it does. E.g. when I put mkdir ~/.test inside .zshrc and execute source .zshrc, the directory .test is created with no problems.

Only with plugins+=(zsh-nvm) I can see that problem, now that the directory is created, here are the error messages:

source .zshrc
Installing nvm...
fatal: destination path '/Users/zaitsev/.nvm' already exists and is not an empty directory.
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
error: pathspec '' did not match any file(s) known to git.
lukechilds commented 7 years ago

Hmmn, what OS and git version are you running?

dmitriz commented 7 years ago

Mac OSX 10.10.5 and git version 2.6.2

lukechilds commented 7 years ago

I don't seem to be able to recreate the issue, the only way I can get the same error as you is if I try and clone into a folder I don't have write access to.

What happens if you run: git clone https://github.com/creationix/nvm.git ~/.test-nvm?

dmitriz commented 7 years ago

No problem:

git clone https://github.com/creationix/nvm.git ~/.test-nvm
Cloning into '/Users/zaitsev/.test-nvm'...
remote: Counting objects: 6025, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 6025 (delta 5), reused 0 (delta 0), pack-reused 6012
Receiving objects: 100% (6025/6025), 1.71 MiB | 247.00 KiB/s, done.
Resolving deltas: 100% (3751/3751), done.
Checking connectivity... done.
lukechilds commented 7 years ago

Do you currently have your brew install in ~/.nvm?

dmitriz commented 7 years ago

Yes, it worked with brew indeed, and ~/.nvm was created, no problem.

lukechilds commented 7 years ago

Ok, could you try adding:

export NVM_DIR="$HOME/.test-zsh-nvm"

to .zshrc before source $ZSH/oh-my-zsh.sh?

dmitriz commented 7 years ago

Working ;)

source ~/.zshrc                                            
Installing nvm...
Cloning into '/Users/zaitsev/.test-zsh-nvm'...
remote: Counting objects: 6025, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 6025 (delta 5), reused 0 (delta 0), pack-reused 6012
Receiving objects: 100% (6025/6025), 1.71 MiB | 1.35 MiB/s, done.
Resolving deltas: 100% (3751/3751), done.
Checking connectivity... done.
lukechilds commented 7 years ago

Hmmmn, that shouldn't be any different to the original install (other than the folder), NVM_DIR will default to "$HOME/.nvm" if it's not set.

If you delete that line from .zshrc and brew uninstall node (make sure that removes ~/.nvm) it should work.

Just re-source ~/.zshrc and it should install into ~/.nvm.

dmitriz commented 7 years ago

I've moved away my .nvm and indeed that is working now. Strange... Thanks in any case, for looking into it and your help!

lukechilds commented 7 years ago

No problem, seems like it was an issue with your environment rather than nvm, glad it's working now.