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