Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uppercase in .nvmrc are handled differently for use and install commands #3417

Closed
thomasfromont-adeo opened this issue Aug 29, 2024 · 6 comments

Comments

@thomasfromont-adeo
Copy link

Operating system and version:

Linux (archlinux)

nvm debug output:

nvm --version: v0.40.1
$SHELL: /bin/zsh
$SHLVL: 2
whoami: 'tfromont'
${HOME}: /home/tfromont
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v18.20.4/bin:${HOME}/.cargo/bin:${HOME}/.local/bin:/opt/google-cloud-cli/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.9 (x86_64-pc-linux-gnu)'
uname -a: 'Linux 6.10.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 19 Aug 2024 17:02:39 +0000 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Arch Linux  ()
awk: /usr/bin/awk, GNU Awk 5.3.0, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)
curl: /usr/bin/curl, curl 8.9.1 (x86_64-pc-linux-gnu) libcurl/8.9.1 OpenSSL/3.3.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0 nghttp2/1.63.0 nghttp3/1.5.0
wget: /usr/bin/wget, GNU Wget 1.24.5 compilé sur linux-gnu.
git: /usr/bin/git, git version 2.46.0
ls: impossible d'accéder à 'grep:': Aucun fichier ou dossier de ce nom
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (GNU grep) 3.11
sed: /usr/bin/sed, sed (GNU sed) 4.9
cut: /usr/bin/cut, cut (GNU coreutils) 9.5
basename: /usr/bin/basename, basename (GNU coreutils) 9.5
rm: /usr/bin/rm, rm (GNU coreutils) 9.5
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 9.5
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.10.0
nvm current: v18.20.4
which node: ${NVM_DIR}/versions/node/v18.20.4/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v18.20.4/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v18.20.4
npm root -g: ${NVM_DIR}/versions/node/v18.20.4/lib/node_modules

nvm ls output:

       v14.21.3
->     v18.20.4
       v20.17.0
        v22.6.0
         system
default -> lts/hydrogen (-> v18.20.4)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v22.6.0) (default)
stable -> 22.6 (-> v22.6.0) (default)
lts/* -> lts/iron (-> v20.17.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.4
lts/iron -> v20.17.0

How did you install nvm?

Archlinux AUR (community package registry) using an AUR helper (yay in my case`

What steps did you perform?

  • default node version is set to node v18
  • a project have a .nvmrc file which contains the following lts/Iron
  • Go to that project and run nvm use

What happened?

  • nvm use commands output an error telling "lts/Iron" is not yet installed

but a corresponding v20 node is already installed, but still running nvm install to be sure

  • nvm install finds the corresponding installed version, and use it

What did you expect to happen?

Expected the nvm use to find the already installed version, like nvm install did, and use it.

To be fair, the workaround is simply to fix the uppercase in the .nvmrc file (from lts/Iron to lts/iron), I just wanted to create the issue if other stumble accross the same behavior.

@ljharb
Copy link
Member

ljharb commented Aug 29, 2024

It indeed should only be lowercase. how did the uppercase version end up in .nvmrc?

@thomasfromont-adeo
Copy link
Author

I guess nobody cared and eventually it got merged like this 😄

@ljharb
Copy link
Member

ljharb commented Aug 29, 2024

so, i'm not sure what nvm should be doing here - lts/Iron was indeed not installed, because lts/iron is the alias nvm knows about.

@thomasfromont-adeo
Copy link
Author

I see two possibilities:

  • either the content of the .nvmrc file has to be well formed, and we can close this issue.
  • or there can be a change in the handling of the content of the file, using the lowercase() function on the input, to match the listed lts aliases

@ljharb
Copy link
Member

ljharb commented Sep 2, 2024

The first bullet point is the case, but that does also mean nvm validates it (npx nvmrc should cover well-formedness, though, which is not the case here - this is just about a missing alias)

Certainly nvm could be case-insensitive with its LTS aliases, but that’s a lot of complexity and implicitness for an exceedingly uncommon case (and now nvm has --save, so hand-written nvmrc files aren’t needed as much)

@ljharb
Copy link
Member

ljharb commented Sep 4, 2024

rereading the OP, the bug seems to be that nvm install worked, not that nvm use didn't. I'll see what I can do.

@ljharb ljharb closed this as completed in 9fb9dec Sep 8, 2024
ljharb added a commit that referenced this issue Mar 11, 2025
New Stuff
 - `install.sh`: add `$ZDOTDIR` to zsh search (#3458)

Fixes
 - `reinstall-packages`: do not reinstall corepack (#3544)
 - avoid bash-specific syntax (#3499)
 - `install-latest-npm`: npm v11 is out
 - `nvm_install_latest_npm`: avoid unbound variable (#3447)
 - give a more helpful message when `lts` alias is mistakenly used (#3441)
 - `nvm ls`, `nvm alias`, `nvm install`: error when an LTS name is invalid
 - `nvm_normalize_lts`: error when an LTS name is not lowercase (#3417)

Documentation
 - [readme] update link
 - [readme] fix `--no-use` example (#3479)
 - [readme] update copyright notice (#3507)
 - [readme] note zsh-nvm's AUTO_USE option (#2670)
 - [readme] add note about reloading zshrc after editing (#3052)
 - [readme] Update shell profile file install notes (#2241)
 - [readme] add docker tips (#2318)
 - [readme] remove `avn` from readme (#3469)
 - [readme] fnm -> nvm.fish (#2541)

Refactors
 - prefer `case` over if/else chains
 - combine `sed -e` invocations/arguments

Tests
 - `nvm exec`/`nvm run`: add `--silent` tests (#1259)
 - [actions] release test needs git tags
 - migrate `installation_iojs` test suite to GitHub Actions (#3476)
 - Migrate slow test suite from Travis CI (#3470)
 - temporarily skip this failing travis test to unblock progress
 - [actions] TOC: use latest LTS node
 - `install.sh`: clean up `nvm_detect_profile` tests
 - `nvm_detect_profile`: refactor (#3467)
 - run urchin tests on pull requests (#3466)
 - update mocks
 - ensure that unit tests use only mocked LTS names
 - [actions] use `node/install` instead of `node/run`

Meta
 - disable blank issues
 - update issue template
 - add DCO (#3456)
 - Rename .github/ISSUE_TEMPLATE.md to .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md (#3454)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants