setup-node icon indicating copy to clipboard operation
setup-node copied to clipboard

`node-version-file` should support absolute paths

Open sidvishnoi opened this issue 2 years ago • 12 comments
trafficstars

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:

  • [x] Ubuntu
  • [ ] macOS
  • [ ] Windows

Runner type:

  • [x] 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
                                                                                      ^^^

sidvishnoi avatar Sep 12 '23 10:09 sidvishnoi

Hello @sidvishnoi. Thank you for your report. We'll take a look on it.

dmitry-shibanov avatar Sep 12 '23 10:09 dmitry-shibanov

Hi folks, I'm running into this issue as well, trying to use ${{ github.action_path }}/.tool-versions but it tries to append the path to the current directory.

It's a pretty frustrating and unexpected behavior as far as I can tell. Any hope to see a fix to this soon? 🙌

evandam avatar Dec 07 '23 17:12 evandam

Can confirm would be nice if it could be looked into. @w3c has a workaround here but less than ideal 🙏

scalp42 avatar Dec 07 '23 17:12 scalp42