nvm use message not formatted properly and saying a version I have installed is not.

Created on 1 Jun 2017  路  15Comments  路  Source: nvm-sh/nvm

  • Operating system and version:
    Mac OS Sierra 10.12.5 (16F73)

  • nvm debug output:


xueye$ nvm debug
nvm --version: v0.31.1
$SHELL: /bin/bash
$HOME: /Users/xueye
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v7.3.0
which node: $NVM_DIR/versions/node/v7.3.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v7.3.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v7.3.0
npm root -g: $NVM_DIR/versions/node/v7.3.0/lib/node_modules

  • nvm ls output:

xueye$ nvm ls
         v4.2.4
         v4.4.4
         v5.6.0
         v6.3.1
         v6.9.2
        v6.10.2
->       v7.3.0
         v7.6.0
         v7.9.0
         system
default -> node (-> v7.9.0)
node -> stable (-> v7.9.0) (default)
stable -> 7.9 (-> v7.9.0) (default)
iojs -> N/A (default)

  • How did you install nvm? (e.g. install script in readme, homebrew):
    I installed it via curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash

  • What steps did you perform?

While using node 7.3, I navigated to my project directory with the following .nvmrc file:

xueye$ cat .nvmrc
v7.9.0

I proceeded to type nvm use which failed. I then tried nvm install which failed.

  • What happened?

I got the following message:

xueye$ nvm use
>ound '/Users/xueye/Work/proj/.nvmrc' with version <v7.9.0
" is not yet installed

xueye$ nvm install
>ound '/Users/xueye/Work/proj/.nvmrc' with version <v7.9.0
' not found - try `nvm ls-remote` to browse available versions.
  • What did you expect to happen?

I expected nvm to switch node the 7.9.0

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?

My ~/.bash_profile is:

xueye$ cat ~/.bash_profile

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

export PATH="$HOME/.node/bin:$PATH"
export PATH="/usr/local/mysql/bin:$PATH"
source ~/.bashrc

export PATH=/Users/xueye/Library/Android/sdk/tools:$PATH
export PATH=/Users/xueye/Library/Android/sdk/platform-tools:$PATH
export PATH="/usr/local/sbin:$PATH"
alias cf='/Users/xueye/.cfscript'

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  source $(brew --prefix)/etc/bash_completion
fi

My .bashrc is:

xueye$ cat ~/.bashrc
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
NPM_PACKAGES="${HOME}/.npm-packages"

# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"

PATH="$NPM_PACKAGES/bin:$PATH"

eval `ssh-agent`
ssh-add ~/.ssh/id_rsa

export NVM_DIR="/Users/xueye/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

export PATH="$HOME/.yarn/bin:$PATH"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Thanks!

Most helpful comment

I'm on a mac and found this issue. Figured out the person who created the .nvmrc file was on a windows machine and the line endings are different there. Recreated the .nvmrc file on my mac and nvm use ran fine. Hope this helps others.

All 15 comments

You appear to have a trailing newline in .nvmrc - what happens if you eliminate that?

Good catch on the newline. If I eliminate that, I get:

xueye$ nvm use
>ound '/Users/xueye/Work/proj/.nvmrc' with version <v7.9.0
 -> N/A" is not yet installed.

xueye$ nvm install
>ound '/Users/xueye/Work/proj/.nvmrc' with version <v7.9.0
' not found - try `nvm ls-remote` to browse available versions.

hmm, the output is definitely messed up (the > that should be on the end of the line is showing up at the beginning).

Any chance you have command or printf aliased to anything?

I just checked, and no, they're normal.

@philbarresi thanks for bearing with me. does nvm_rc_version print out the same thing?

If so, what about read -r NVM_RC_VERSION < "/Users/xueye/Work/proj/.nvmrc" ; echo "$?|$NVM_RC_VERSION"?

No problem! Thanks for all the support!

xueye$ nvm_rc_version
>ound '/Users/xueye/Work/proj/.nvmrc' with version <7.9

xueye$ read -r NVM_RC_VERSION < "/Users/xueye/Work/proj/.nvmrc" ; echo "$?|$NVM_RC_VERSION"
0|7.9

ok, so basically the only command being ran there between the read and the nvm_rc_version output is nvm_echo "Found '${NVMRC_PATH}' with version <${NVM_RC_VERSION}>".

Can you run that command and provide the output (assuming $NVM_RC_VERSION is set to 7.9 and $NVMRC_PATH is set to /Users/xueye/Work/proj/.nvmrc), and then if that's still got the misplaced >, provide the full output of type nvm_echo?

@philbarresi any chance you could provide this output?

I also had a trailing newline in my .nvmrc file, as per https://github.com/creationix/nvm#nvmrc

The contents of a .nvmrc file must be the (as described by nvm --help) followed by a newline. No trailing spaces are allowed, and the trailing newline is required.

However, we were receiving the following message:

```A: version "8.10.0
-> N/A" is not yet installed.

`8.10.0` is definitely installed, as `nvm ls` output demonstrated (also, .nvrcm output below):

```        v6.10.3 *
->       v8.2.1 *
        v8.10.0 *
default -> 8.2.1 (-> v8.2.1 *)
node -> stable (-> v8.10.0 *) (default)
stable -> 8.10 (-> v8.10.0 *) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.1 (-> N/A)
lts/carbon -> v8.11.1 (-> N/A)
Found '[path/to/].nvmrc' with version <8.10.0
>

Note how the newline is included in the version.

When I removed the "required" trailing newline, nvm use worked perfectly.

NOTE: AFAIK we are not using CR/LF in our project; all dev is done on Mac OS and build is on Ubuntu.

What prints out if you explicitly printf '|' && cat .nvmrc && printf '|'?

SSH: EXEC: STDOUT/STDERR from command [cd pr/86 && printf '|' && cat .nvmrc && printf '|' && nvm use && npm install && chmod a+x ./wkhtmltopdf && npm run test:js] ...
|8.10.0
|Found '/home/jenkins/pr/86/.nvmrc' with version <8.10.0
>
N/A: version "8.10.0
 -> N/A" is not yet installed.

You need to run "nvm install 8.10.0
" to install it before using it.

The hexdump suggests only the newline (0A) is present:

  Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F   
00000000: 38 2E 31 30 2E 30 0A                               8.10.0.

Again, Mac OS, build output above was run on an Ubuntu image, and editing (including hexdump) done in VS Code.

interesting, thanks for the followup.

I think that since the documentation specifies it, what we need to do is alter the .nvmrc parsing so that it can handle trailing newlines. It's possible #1740 addresses this; are you able to update to the latest master and try there?

Just noticed you asked me to try a new version; I'll try to get that done this week and let you know.

I can confirm that v0.33.11 does not experience this issue.

With or without a trailing newline, nvm parses the .nvmrc file correctly for me.

I'm on a mac and found this issue. Figured out the person who created the .nvmrc file was on a windows machine and the line endings are different there. Recreated the .nvmrc file on my mac and nvm use ran fine. Hope this helps others.

Was this page helpful?
0 / 5 - 0 ratings