lukechilds / zsh-nvm

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

Problem installing the plugin when there is nvm already installed #11

Closed drinchev closed 8 years ago

drinchev commented 8 years ago

I have a problem installing zsh-nvm via antigen

    λ ~ ◆ antigen bundle lukechilds/zsh-nvm
    .Cloning into '/Users/drinchev/.antigen/repos/https-COLON--SLASH--SLASH-github.com-SLASH-lukechilds-SLASH-zsh-nvm.git'...
    remote: Counting objects: 228, done.
    remote: Compressing objects: 100% (47/47), done.
    remote: Total 228 (delta 16), reused 0 (delta 0), pack-reused 178
    Receiving objects: 100% (228/228), 29.54 KiB | 0 bytes/s, done.
    Resolving deltas: 100% (91/91), done.
    Checking connectivity... done.
    Installing nvm...
    fatal: destination path '/Users/drinchev/.nvm' already exists and is not an empty directory.
    fatal: Not a git repository (or any of the parent directories): .git
    fatal: Not a git repository (or any of the parent directories): .git
    λ ~ ◆ 

I already have nvm installed on my machine ( OS X El Capitan )

Additional information :

    λ ~ ◆ [[ ! -f "$NVM_DIR/nvm.sh" ]] && echo "nvm doesn't exist" || echo "nvm exists"
    nvm doesn't exist
    λ ~ ◆ echo $NVM_DIR
    /Users/drinchev/.nvm
    λ ~ ◆ ls -lah $NVM_DIR
    total 0
    drwxr-xr-x   5 drinchev staff  170 Oct 24  2015 .
    drwxr-xr-x+ 94 drinchev staff 3.2K Oct 18 23:23 ..
    drwxr-xr-x   3 drinchev staff  102 Oct 24  2015 alias
    drwxr-xr-x   4 drinchev staff  136 Sep 10 19:20 bin
    drwxr-xr-x   3 drinchev staff  102 Oct 24  2015 versions
    λ ~ ◆
lukechilds commented 8 years ago

Thanks for taking the time to submit an issue 👍

That's very strange, it doesn't look like a valid nvm install, there's lots of files missing. What does nvm --version output?

Also, could you paste the line you're using to source your existing install?

drinchev commented 8 years ago

You are totally right.

λ ~ ◆ nvm --version
0.30.1
λ ~ ◆ cat ~/.zshrc | grep nvm
plugins=(git aws brew brew-cask cp coffee emoji node npm nvm osx rsync sublime k catimg)
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
λ ~ ◆ brew --prefix nvm
/usr/local/opt/nvm
λ ~ ◆

I got your idea. Probably nvm was installed via brew and this is just a leftover.

lukechilds commented 8 years ago

Ahh Homebrew installation isn't recommended by nvm, it doesn't export the NVM_DIR environment variable which makes it pretty much impossible to work with and causes crazy bugs like this haha.

This isn't really a bug in zsh-nvmyou just have a bit of a mangled install. To fix run rm -rf ~/.nvm and comment out export NVM_DIR=~/.nvm in .zshrc. That will clear your old broken install. Now zsh-nvm will be able to install, however it won't pick up your brew install (because the brew version doesn't export NVM_DIR) so it will pull a fresh copy of nvm into ~/.nvm.

You can then copy the /usr/local/opt/nvm/v* and /usr/local/opt/nvm/alias directories to ~/.nvm to migrate your node installs/aliases from your brew nvm to your zsh-nvm nvm. Then you can safely run brew uninstall nvm and you won't lose any of your node versions.

You'll then have nvm installed via an offically supported install method (git) and also be able to keep up to date with nvm updates with nvm upgrade/nvm revert. Lazy loading is also worth checking out 👍

lukechilds commented 8 years ago

@drinchev Did you get this sorted? Can I close the issue?

drinchev commented 8 years ago

Yes, please close the issue.

Sent from my iPhone

On 22 Oct 2016, at 17:46, Luke Childs notifications@github.com wrote:

@drinchev Did you get this sorted? Can I close the issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.