Skip to content

nvm depends on nullglob but doesn't require nor set it #3727

Description

@balupton

Operating system and version:

nvm debug output:

Details
nvm --version: v0.40.3
$TERM_PROGRAM: ghostty
$SHELL: /opt/homebrew/bin/bash
$SHLVL: 3
whoami: 'balupton'
${HOME}: /Users/balupton
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.config/carapace/bin:${HOME}/.local/share/dorothy/user/commands.local:${HOME}/.local/share/dorothy/user/commands:${HOME}/.local/share/dorothy/commands.deprecated:${HOME}/.local/share/dorothy/commands.beta:${HOME}/.local/share/dorothy/commands:${HOME}/.local/bin:${HOME}/bin:/Applications/1Password.app/Contents/MacOS:/usr/local/bin:/opt/homebrew/Cellar/go/1.25.4/bin:${HOME}/.cargo/bin:/opt/homebrew/opt/openssl/bin:/opt/homebrew/Cellar/node/25.2.1/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/opt/gettext/bin:/opt/homebrew/opt/icu4c/sbin:/opt/homebrew/opt/icu4c/bin:/opt/homebrew/opt/sqlite/bin:/opt/homebrew/opt/llvm/bin:/opt/homebrew/bin:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.1.sdk/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Library/Developer/CommandLineTools/usr/bin:/usr/bin:/usr/sbin:/sbin:/bin:/System/Cryptexes/App/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/pmk/env/global/bin:/Library/Apple/usr/bin:/Applications/VMware Fusion Tech Preview.app/Contents/Public:/opt/podman/bin:/Applications/Ghostty.app/Contents/MacOS:${HOME}/.lmstudio/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.3.8(1)-release (aarch64-apple-darwin25.1.0)'
uname -a: 'Darwin 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:47 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T8103 arm64'
checksum binary: 'sha256sum'
OS version: macOS 26.1 25B78
awk: /usr/bin/awk, awk version 20200816
curl: /usr/bin/curl, curl 8.7.1 (x86_64-apple-darwin25.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.67.1
wget: /opt/homebrew/bin/wget, GNU Wget 1.25.0 built on darwin23.6.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /opt/homebrew/bin/git, git version 2.52.0
grep: /usr/bin/grep, grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
nvm current: system
which node: /opt/homebrew/Cellar/node/25.2.1/bin/node
which iojs:
which npm: /opt/homebrew/Cellar/node/25.2.1/bin/npm
npm config get prefix: /opt/homebrew
npm root -g: /opt/homebrew/lib/node_modules

nvm ls output:

Details
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory

->       system
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
default -> system
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
lts/* -> lts/krypton (-> N/A)
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 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.8 (-> N/A)
lts/iron -> v20.19.6 (-> N/A)
lts/jod -> v22.21.1 (-> N/A)
lts/krypton -> v24.11.1 (-> N/A)

How did you install nvm?

What steps did you perform?

$ ls /Users/balupton/.nvm/versions/node
v24.11.1        v25.2.1

$ nvm-env -- nvm uninstall 24.11.1
Uninstalled node v24.11.1

$ nvm-env -- nvm uninstall 25.2.1
Uninstalled node v25.2.1

$ nvm-env -- nvm ls --no-colors --no-alias
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory

->       system *
$ bash -c 'source /Users/balupton/.local/share/dorothy/sources/nvm.sh; nvm ls --no-colors --no-alias'
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory

->       system *
$ cat /Users/balupton/.local/share/dorothy/sources/nvm.sh
#!/usr/bin/env sh

# ensure NVM_DIR, always set as always applicable right now
if [ -z "${NVM_DIR-}" ]; then
        export NVM_DIR="$HOME/.nvm"
fi

# check nvm is non-empty
if [ -s "$NVM_DIR/nvm.sh" ]; then
        # we have nvm
        # check if we can access node
        if ! command which node >/dev/null 2>&1; then
                # then reload the environment, as this occurs when the node version changes in the host environment, as such nvm is no longer able to detect it via its [command which node]
                . "$DOROTHY/sources/environment.sh"
        fi
        # we have nvm, and should now have node, so load nvm
        . "$NVM_DIR/nvm.sh"
elif [ -d "$NVM_DIR" ]; then
        # we have nvm, but it is corrupted, so remove it
        fs-remove --quiet --no-confirm -- "$NVM_DIR"
fi

What happened?

I get these errors:

find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory
find: /Users/balupton/.nvm/versions/node/*: No such file or directory

Whereas, this works:

bash -c 'shopt -s nullglob; source /Users/balupton/.local/share/dorothy/sources/nvm.sh; nvm ls --no-colors --no-alias'

->       system *

What did you expect to happen?

It to error that nullglob is required and must be set by the user, or for nvm to enforce nullglob itself.

Is there anything in any of your profile files that modifies the PATH?

Not relevant.

If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?

Details

For now, I'll just adjust https://github.com/bevry/dorothy/blob/master/commands/nvm-env to set nullglob.

Activity

  1. ljharb commented on Nov 30, 2025

    @ljharb
    Member

    I'm a bit confused. You're saying there's a bash option nullglob that, if set, breaks nvm?

  2. balupton commented on Nov 30, 2025

    @balupton
    Author

    I'm a bit confused. You're saying there's a bash option nullglob that, if set, breaks nvm?

    That when nullglob is not set, nvm breaks.

    nullglob and failglob are two exclusive behaviours for dealing with empty glob patterns, whereas nvm requires nullglob; and it seems circumstantial to what is the default that is inherited

    nvm should be setting nullglob for itself (which it can do only for itself by running within a subshell, eg. parens instead of squigglies), or hard failing if nullglob is not set with an appropriate enable nullglob message

    however, I'm happy for this to be closed as an edge case, as I already have a workaround in my setup where i set nullglob for nvm myself

  3. ljharb commented on Dec 1, 2025

    @ljharb
    Member

    Nah, that's something we should work around, just like we do with a nondefault IFS.

  4. added
    pull request wantedThis is a great way to contribute! Help us out :-D
    and removed
    needs followupWe need some info or action from whoever filed this issue/PR.
    on Dec 1, 2025
  5. Rahulbeniwal26119 commented on Dec 1, 2025

    @Rahulbeniwal26119
    Contributor

    @ljharb I would love to work on this. Please assign this to me.
    Thank You

  6. ljharb commented on Dec 1, 2025

    @ljharb
    Member

    Nothing is ever assigned in open source; just open a PR and it'll be reviewed when there's time.

  7. added 4 commits that reference this issue on Dec 5, 2025
    1a95084
    da2a20f
    9449392
    dc76607
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions