setup-node
setup-node copied to clipboard
Cache can't be used in workspaces
Description: When using a repo with workspaces and the latest node versions (which also bundle more up-to-date npm versions), actions fail because it can't retrieve the cache path.
Updating the action version doesn't change anything. I'm sure this is the same thing as https://github.com/npm/cli/issues/6099 but I'm opening this as I think it fits here too, so people affected by this can find this ticket. Maybe there's also some workaround or you can push a bit the npm team to get this fixed quickier :)
Action version:
v3.5.1
Platform:
- [X] Ubuntu
- [ ] macOS
- [ ] Windows
Runner type:
- [X] Hosted
- [ ] Self-hosted
Tools version:
node: v18.15.0
yarn: 1.22.19
npm: 9.5.0
Repro steps:
- Create a repository with npm workspaces
- Enable cache for the workflow
- Set a workspace by default, like we did in our .npmrc
Expected behavior: Cache works as expected and the action succeeds
Actual behavior: The action halts completely
Hello @ferferga ! Thank you for reporting this! We will investigate the issue
I hope this fixes the issues. The error message suggests that the npm config get cache command is not supported when running with workspaces. To fix this error, you can set the --ignore-workspaces flag when running the npm command. Here's an updated version of the code
Run @.***
Attempt to resolve the latest version from manifest...
Resolved as '18.15.0'
Attempting to download 18.15.0...
Acquiring 18.15.0 - x64 from https://github.com/actions/node-versions/releases/download/18.15.0-4362038354/node-18.15.0-linux-x64.tar.gz
Extracting ...
/usr/bin/tar xz --strip 1 --warning=no-unknown-keyword -C /home/runner/work/_temp/1c9849b8-5616-425f-b0bf-ab2eb5377e6d -f /home/runner/work/_temp/526a4e8e-a4af-491c-ab91-c333c883911b
Adding to the cache ...
Done
Environment details
/opt/hostedtoolcache/node/18.15.0/x64/bin/npm --ignore-workspaces config get cache
By using the --ignore-workspaces flag, the npm config get cache command should now run successfully without the ENOWORKSPACES error.
On Tue, Mar 14, 2023 at 8:21 AM MaksimZhukov @.***> wrote:
Hello @ferferga https://github.com/ferferga ! Thank you for reporting this! We will investigate the issue
— Reply to this email directly, view it on GitHub https://github.com/actions/setup-node/issues/712#issuecomment-1468005908, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVLQYUOQFUBQMOVL7ERRY6DW4BPDLANCNFSM6AAAAAAV2HNBBQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@yandyestrada That's an interesting workaround, thank you!
@MaksimZhukov I think it might be a good idea to invoke the command with the flag, even after npm gets the issue fixed (as far as I understand from the issue at their repo, it's a regression and not an intended bheaviour). I guess it shouldn't harm? Some configs might be workspace-related, but I'm not aware that's the case with the cache path.
you're welcome anytime...
On Tue, Mar 14, 2023 at 8:36 AM Fernando Fernández @.***> wrote:
@yandyestrada https://github.com/yandyestrada That's an interesting workaround, thank you!
@MaksimZhukov https://github.com/MaksimZhukov I think it might be a good idea to invoke the command with the flag, even after npm gets the issue fixed (as far as I understand from the issue at their repo, it's a regression and not an intended bheaviour). I guess it shouldn't harm? Some configs might be workspace-related, but I'm not aware that's the case with the cache path.
— Reply to this email directly, view it on GitHub https://github.com/actions/setup-node/issues/712#issuecomment-1468026690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVLQYUOJD26RPEZSDFT4VJLW4BQ5VANCNFSM6AAAAAAV2HNBBQ . You are receiving this because you were mentioned.Message ID: @.***>
@yandyestrada I tried locally with the --ignore-workspaces
argument and it doesn't work, so we can't even workaround this that way.
Ok did you guys found a away around and fixed it?
On Wed, Mar 15, 2023 at 1:19 PM Fernando Fernández @.***> wrote:
@yandyestrada https://github.com/yandyestrada I tried locally with the --ignore-workspaces argument and it doesn't work, so we can't even workaround this that way.
— Reply to this email directly, view it on GitHub https://github.com/actions/setup-node/issues/712#issuecomment-1470440215, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVLQYUJUPVABS2ITUNEE7ADW4H2ZHANCNFSM6AAAAAAV2HNBBQ . You are receiving this because you were mentioned.Message ID: @.***>
-- Yandy Estrada CENTURY 21 Rosa Leon REALTOR® / Office Manager 7025 W Hillsborough Ave Tampa FL 33634 @.*** (813) 679-4958
Hello @ferferga,
I tried to reproduce the problem but the workflow does not fail:
1st run (create cache for /home/runner/.npm
): https://github.com/akv-demo/setup-node-test/actions/runs/7285452258/job/19852384806#step:7:19
2nd run (use cache) https://github.com/akv-demo/setup-node-test/actions/runs/7285452258/job/19854946248#step:3:65
The mentioned issue https://github.com/npm/cli/issues/6099 does not seem to relate to this issue because it appears if npm config get
runs in the package's folder, but the action calls npm config get cache
from within the project root and it does not produce the error: https://github.com/akv-demo/setup-node-test/actions/runs/7287031387/job/19856858523#step:4:15
Can you please help us with the reproducing the problem?
@dsame you need to set workspaces=true
in .npmrc to reproduce the error
I'm working around this by running setup-node with
env:
npm_config_workspaces: false