Repository navigation
Unable to set global npm version, npm v8 is always used... #376
Description
Activity
i should add: this pipeline has been working without issue for months. my last successful run was ~7days ago (11/30/2021 - log). i noticed things failing starting yesterday (12/6/2021)
edit: comparing the last successful run to my recent failures, i see
Current runner version: '2.284.0'(success) vs.Current runner version: '2.285.1'(fail). looks like the earliest failure happened underCurrent runner version: '2.285.0'which was released ~8days ago (info)edit: this seems relevant 👉 actions/runner#1439
edit: doesn't look like i can downgrade the runner itself ☠️
edit: actions/runner#1439 (comment) seems to confirm my expectation that
setup-nodewould handle things such that the base environment wouldn't conflict with the environment where my actions runmy last successful run was ~7days ago (11/30/2021 - log).
Your repository is private and I cannot see the runs. When I try to reproduce this, I am running the expected versions of node and npm after running setup-node.
steps: - uses: actions/setup-node@v2 with: node-version: '12' - name: Debug env: NPM_TOKEN: foobar run: | echo ":::: NPM SETTINGS" node --version npm --version
shows:
:::: NPM SETTINGS v12.22.7 6.14.15Is this what you're seeing? Or are you seeing something different from
node --versionandnpm --version? Is this only failing in thenpm run buildstep or are you seeing odd version numbers before that step?@ethomson thanks for taking a look 🙏
Is this only failing in the npm run build step
correct. i'm running a tool via the
npm run buildcommand that then builds my source code. the line that is triggering the warnings is hereYour repository is private and I cannot see the runs
as you are a Github employee, i'm happy to grant you access. fwiw, we are a Github Enterprise customer (info). if it's helpful, i can file a ticket.
ok, should have done this from the beginning but better late than never. running locally (edit: outside of GH Actions entirely), i'm able to reproduce the warnings and subsequent failures by simply running under
npm@8. edit: reverting tonpm@6and re-running fixes things.so the question really boils down to: why would a call to execute
npmfrom a node.js script cause the base environment'snpminstance to be used instead of the one configured viasetup-node?I should also note that I’m using the setup-node action to control node + npm versions as well (not exclusively via
npm ibut both together)- uses: actions/setup-node@v2 with: node-version: '12' registry-url: 'https://registry.npmjs.org' - name: Install Dependencies run: | npm ci env: NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}Hello @busticated. Thank you for your report. Could you please provide a public repository to reproduce the issue. I've tried from my side, but it works as expected.
so the question really boils down to: why would a call to execute npm from a node.js script cause the base environment's npm instance to be used instead of the one configured via setup-node?
I don't have an answer for you - I'd love to know if
echo ":::: NPM SETTINGS" node --version npm --versionis producing the expected values?
Expanding on this, I'd love to know what you're seeing here:
run: | echo ":::: NPM SETTINGS" npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" node --version npm --version node -e 'child_process.spawnSync("npm", ["--version"], { stdio: "inherit" });' node -e 'child_process.spawnSync("which", ["npm"], { stdio: "inherit" });' npm i npm@6 --global npm --version node -e 'child_process.spawnSync("npm", ["--version"], { stdio: "inherit" });' node -e 'child_process.spawnSync("which", ["npm"], { stdio: "inherit" });'For this, I get all the expected outputs:
:::: NPM SETTINGS v12.22.7 6.14.15 6.14.15 /opt/hostedtoolcache/node/12.22.7/x64/bin/npm /opt/hostedtoolcache/node/12.22.7/x64/bin/npm -> /opt/hostedtoolcache/node/12.22.7/x64/lib/node_modules/npm/bin/npm-cli.js /opt/hostedtoolcache/node/12.22.7/x64/bin/npx -> /opt/hostedtoolcache/node/12.22.7/x64/lib/node_modules/npm/bin/npx-cli.js + [email protected] updated 1 package in 15.958s 6.14.15 6.14.15 /opt/hostedtoolcache/node/12.22.7/x64/bin/npmIf you're seeing this, too, then I think that your question here is very interesting, indeed:
so the question really boils down to: why would a call to execute npm from a node.js script cause the base environment's npm instance to be used instead of the one configured via setup-node?
I'd love to know how you're invoking npm from this Node.js script.
thanks @ethomson 🙏
i ran the debug step you provided along with a few more bits like changing directories to see if that mattered any and got the same results as you did:
[email protected]is always reported.the code that is executing is somewhat tricky:
- first the
npm run buildcommand is run from a top-level node package - that command then calls down into a child node package (we're in a monorepo) which then executes
oclif-dev pack,oclif-dev pack:win, andoclif-dev pack:debin that order via its ownnpm run buildcommand. the command that fails isoclif-dev pack:deb(the last one) oclif-dev pack:debitself tries to build tarballs (1) and errors out upon runningnpm install --productionvia child process(2)
i patched the underlying lib to output more debugging info and discovered something interesting. all of the
oclif-devcommands i listed above run the "build tarballs" step. when i log outwhich npmin the context of that code, i see:@particle/cli: > oclif-dev pack @particle/cli: /opt/hostedtoolcache/node/12.22.7/x64/bin/npm - - - @particle/cli: > oclif-dev pack:win @particle/cli: /opt/hostedtoolcache/node/12.22.7/x64/bin/npm - - - @particle/cli: > oclif-dev pack:deb @particle/cli: /usr/local/bin/npm(with a bunch of noise omitted)
so, at some point this code starts seeing
/usr/local/bin/npmas the output ofwhich npmand of course this version is[email protected].i then tried running the
oclif-dev pack:debstep on its own thinking maybe previous steps messed things up somehow and that failed on its own.but here's the wrinkle - the
oclif-dev pack:debstep is run likesudo -s -E oclif-dev pack:debb/c the command requires root (issue, pr).is that likely to be the culprit? and what changed to cause failures now? is it down to the base environment change rolled out in https://github.com/actions/runner/releases/tag/v2.285.0 ?
- first the
ok, well adding
sudo -s -E npm i npm@6 --globaljust prior to callingnpm run buildfixes things. so, yay?i suppose you can close this out - thanks for the help 🙏 👍
oho tenku
god blesu evribare
Hello everyone. For now I'm closing the issue. If you have any concerns feel free to contact us.
Thank you for the help @ethomson .- added a commit that references this issue
on Nov 9, 2023
Description:
I need to run my action using
npm@6. Despite installing the correct version globablly,npm@8is always used and my action fails. i see a series of warnings in my logs like:i first noticed the failure on monday (12/6/2021), the last successful run was ~7days ago (11/30/2021 - log)
inspecting the logs for both runs, i see
Current runner version: '2.284.0'(success) vs.Current runner version: '2.285.1'(fail). looks like the earliest failure happened underCurrent runner version: '2.285.0'which was released ~8days ago (info)running locally (outside of GH Actions entirely but within a comparable environment), i'm able to reproduce the warnings and subsequent failures by simply using
npm@8. at no point does my code attempt to installnpm@8. reverting tonpm@6and re-running fixes things.the
Unsupported enginewarnings are triggered by running a tool which itself runsnpmvia child-process in a descendant directory (see here). this is what mynpm run buildcommand does under the hood.interestingly, Node.js
v12.22.7ships w/[email protected]by default (see ~pg10 here) so something is explicitly pulling in[email protected]somewhereAction version:
v2.5.0,v2.4.1, andv2.4.0Platform:
Runner type:
Tools version:
node:
v12.22.7npm:
6.14.15(but[email protected]is always used)Repro steps:
Using an action step like:
(note: using either
ubuntu-18.04orubuntu-latestyields the same result)Expected behavior:
npm run buildcommand succeeds,npm@6is usedActual behavior:
npm run buildfails with the following log output:npm@8is used despite previously installingnpm@6vianpm i npm@6 --globaland despite Node.jsv12.22.7shipping with[email protected]by default