actions / actions/setup-node

`node-version-file` should support absolute paths

Open
#852 12 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
TypeScript
Stars
5k
Forks
1.7k
Avg merge
3d 12h
Merged PRs (30d)
2

Description

Description:

If we pass a absolute path to node-version-file, for example, when using with Composite Actions, the resulting path is resolved incorrectly, due to a path.join() call.

https://github.com/actions/setup-node/blob/5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d/src/main.ts#L96-L100

Action version:
v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Repro steps:

  1. In a composite action with .nvmrc, use following as input:
    node-version-file: ${{ github.action_path }}/.nvmrc
    

Example broken action run: https://github.com/sidvishnoi/mediasession/actions/runs/6158104300/job/16710218833?pr=1

Expected behavior:

If it can check whether provided node-version-file exists as is, or perhaps use path.resolve(), it won't break with absolute paths.

Actual behavior:

Error: The specified node version file at: /home/runner/work/mediasession/mediasession/home/runner/work/_actions/w3c/spec-prod/fix-nvmrc/.nvmrc does not exist
                                                                                      ^^^

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/main.ts around lines 96-100, where node-version-file is resolved, and reproduce the composite-action example using an absolute .nvmrc path. Verify that absolute paths are checked without being prefixed again, while relative paths continue to work and the reported missing-file error is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
ci-cd, devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.