nodeenv falls back to /usr/bin/nodejs instead of the node installed by actions/setup-node
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5k
- Forks
- 1.7k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 2
Description
Description:
In a runs-on: ubuntu-latest GitHub hosted runner, I found that even after doing:
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16
that pre-commit run -a was failing to run a pre-commit hook configured as:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
args: [--no-editorconfig]
exclude: "^asv\\.conf\\.json$"
exclude_types: [html]
with an error saying:
prettier requires at least version 14 of Node, please upgrade
Which was surprising, seeing as how we had just installed node version 16.
It turns out that pre-commit runs nodeenv, and nodeenv looks first for a binary named nodejs, and then falls back to looking for one named node:
And it seems like actions/setup-node is only installing one named node, and not one named nodejs, so nodeenv found /usr/bin/nodejs first and preferred that over /opt/hostedtoolcache/node/16.20.2/x64/bin/node.
Should the hostedtoolcache contain a nodejs as well? Or perhaps nodeenv should prefer node over nodejs?
Action version:
actions/setup-node@v4
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Tools version:
Repro steps:
See https://github.com/bloomberg/memray/actions/runs/6984525297/job/19007471664 for a failed run where /usr/bin/nodejs was chosen instead of /opt/hostedtoolcache/node/16.20.2/x64/bin/node
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the actions/setup-node@v4 workflow and the nodeenv.py lookup around lines 931-938, then reproduce the failing pre-commit run from the linked GitHub Actions job. Trace which executable is selected on Ubuntu hosted runners; the issue is done when the configured Node 16 installation is selected and the Prettier hook succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, node.js, typescript
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100