Skip to content
Permalink
Browse files

[Docs] [Fix] Set $NVM_DIR to ".nvm" instead of "nvm"

- Operating system and version: Mac OS X Mojave

- What happened? $NVM_DIR was set to nvm

- What did you expect to happen? $NVM_DIR should be set to .nvm
I added the following line from the README to my .zshrc:
```
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
```

I couldn't figure out why nvm wasn't loading, until I realized that
`echo NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"` outputs `NVM_DIR=nvm`.

Changing the line to `export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/}.nvm"` fixed the problem. This outputs `NVM_DIR=.nvm` as expected. I tested this and the same behavior holds true in Bash as well.
  • Loading branch information...
wpapper authored and ljharb committed Apr 24, 2019
1 parent 6537c91 commit 3cc9525dceacb1d7376df85aa14167bc0cacc5e1
Showing with 2 additions and 6 deletions.
  1. +1 −1 README.md
  2. +1 −5 install.sh
@@ -61,7 +61,7 @@ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
<sub>**Note:** If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.</sub>

```sh
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
```

@@ -7,11 +7,7 @@ nvm_has() {
}

nvm_default_install_dir() {
if [ -n "${XDG_CONFIG_HOME-}" ]; then
printf %s "${XDG_CONFIG_HOME}/nvm"
else
printf %s "${HOME}/.nvm"
fi
[ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm"
}

nvm_install_dir() {

0 comments on commit 3cc9525

Please sign in to comment.
You can’t perform that action at this time.