Skip to content

bug: npm shim finding incorrect binary #2133

@johnseekins-pathccm

Description

@johnseekins-pathccm

Describe the Bug

I believe this is similar to #2085

Somehow, asdf is using node libraries in Homebrew instead of correctly using the paths in ~/.asdf/installs. Reproduction is fairly easy: Just install any hombrew package that has node as a dependency (e.g. markdownlint-cli).

Steps to Reproduce

brew install markdownlint-cli
rm -r ~/.asdf/installs/nodejs/22.15.0
mkdir -p ~/projects/pnpm-test
cd ~/projects/pnpm-test
echo "nodejs 22.15.1" > .tool-versions
asdf install
npm -dd i -g pnpm

Expected Behaviour

pnpm is installed to the expected node path.

Actual Behaviour

version 22.15.1 of nodejs is already installed
version 3.12.2 of python is already installed
npm verbose cli /Users/johnseekins/.asdf/installs/nodejs/22.15.1/bin/node /opt/homebrew/bin/npm
npm info using npm@11.3.0
npm info using node@v22.15.1
npm warn -dd is not a valid single-hyphen cli flag and will be removed in the future
npm verbose title npm i pnpm
npm verbose argv "--loglevel" "verbose" "i" "--global" "pnpm"
npm verbose logfile logs-max:10 dir:/Users/johnseekins/.npm/_logs/2025-06-11T14_34_08_102Z-
npm verbose logfile /Users/johnseekins/.npm/_logs/2025-06-11T14_34_08_102Z-debug-0.log
npm http fetch GET 200 https://registry.npmjs.org/pnpm 418ms (cache revalidated)
npm verbose stack Error: EACCES: permission denied, rename '/opt/homebrew/lib/node_modules/pnpm' -> '/opt/homebrew/lib/node_modules/.pnpm-vYOM5RrQ'
npm verbose stack at async Object.rename (node:internal/fs/promises:778:10)
npm verbose stack at async moveFile (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/fs/lib/move-file.js:30:5)
npm verbose stack at async Promise.allSettled (index 0)
npm verbose stack at async [reifyPackages] (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:336:11)
npm verbose stack at async Arborist.reify (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:141:5)
npm verbose stack at async Install.exec (/opt/homebrew/lib/node_modules/npm/lib/commands/install.js:149:5)
npm verbose stack at async Npm.exec (/opt/homebrew/lib/node_modules/npm/lib/npm.js:208:9)
npm verbose stack at async module.exports (/opt/homebrew/lib/node_modules/npm/lib/cli/entry.js:67:5)
npm error code EACCES
npm error syscall rename
npm error path /opt/homebrew/lib/node_modules/pnpm
npm error dest /opt/homebrew/lib/node_modules/.pnpm-vYOM5RrQ
npm error errno -13
npm error Error: EACCES: permission denied, rename '/opt/homebrew/lib/node_modules/pnpm' -> '/opt/homebrew/lib/node_modules/.pnpm-vYOM5RrQ'
npm error at async Object.rename (node:internal/fs/promises:778:10)
npm error at async moveFile (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/fs/lib/move-file.js:30:5)
npm error at async Promise.allSettled (index 0)
npm error at async [reifyPackages] (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:336:11)
npm error at async Arborist.reify (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:141:5)
npm error at async Install.exec (/opt/homebrew/lib/node_modules/npm/lib/commands/install.js:149:5)
npm error at async Npm.exec (/opt/homebrew/lib/node_modules/npm/lib/npm.js:208:9)
npm error at async module.exports (/opt/homebrew/lib/node_modules/npm/lib/cli/entry.js:67:5) {
npm error errno: -13,
npm error code: 'EACCES',
npm error syscall: 'rename',
npm error path: '/opt/homebrew/lib/node_modules/pnpm',
npm error dest: '/opt/homebrew/lib/node_modules/.pnpm-vYOM5RrQ'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It is likely you do not have the permissions to access this file as the current user
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.
npm verbose cwd /Users/johnseekins/projects/pnpm-test
npm verbose os Darwin 24.5.0
npm verbose node v22.15.1
npm verbose npm v11.3.0
npm verbose exit -13
npm verbose code -13
npm error A complete log of this run can be found in: /Users/johnseekins/.npm/_logs/2025-06-11T14_34_08_102Z-debug-0.log


### Environment

```shell
$ asdf info
OS:
Darwin NN4RXFV5QY 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020 arm64

SHELL:
zsh 5.9 (arm64-apple-darwin24.0)

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
0.18.0 (revision unknown)

ASDF INTERNAL VARIABLES:
ASDF_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/johnseekins/.asdf
ASDF_CONFIG_FILE=/Users/johnseekins/.asdfrc

ASDF INSTALLED PLUGINS:
golang    https://github.com/asdf-community/asdf-golang.git
          50c8f58237da34223d31ac9e62e5d5f8dcc13f5f
java      https://github.com/halcyon/asdf-java.git
          71dd375fbb8c299fd888c88d132c3baa230c23d7
lua       https://github.com/Stratus3D/asdf-lua.git
          1ebd84967ed6b7aefeb4300cfcb211f414be0226
mkcert    https://github.com/salasrod/asdf-mkcert.git
          8287d3c115b6c681592f44b2060973af6ae24be3
nodejs    https://github.com/asdf-vm/asdf-nodejs.git
          fd2c7f94c4c71416047cacf2af6e4fa819b364b7
opentofu  https://github.com/virtualroot/asdf-opentofu.git
          a61ef50be11456f93809bcd18f064d4e5a6cdce1
php       https://github.com/asdf-community/asdf-php.git
          52c669a77f08ec81caff47d560476d2ba1b176b9
python    https://github.com/danhper/asdf-python.git
          d4caa7d4832313b4c141ee0ceca4118747147e89
ruby      https://github.com/asdf-vm/asdf-ruby.git
          e26f34622ffe68d14baeb3ab0da533281f805891
terraform https://github.com/asdf-community/asdf-hashicorp.git
          22eb1c4a16adcde39aaaf89fbb5d9404a1601fce
uv        https://github.com/asdf-community/asdf-uv.git
          ce093c3592cee00029413c75c896d7c29e1bd51a

asdf plugins affected (if relevant)

I don't believe this affects a single plugin. The reproduction is very simple using nodejs, though.

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