Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to v2.3/v2.4 results in post-setup failure #317

Closed
khitrenovich opened this issue Aug 10, 2021 · 15 comments
Closed

Upgrade to v2.3/v2.4 results in post-setup failure #317

khitrenovich opened this issue Aug 10, 2021 · 15 comments
Assignees

Comments

@khitrenovich
Copy link

We are using actions/setup-node v2.2 in Yarn-based monorepo. We attempted upgrade to v2.3 and v2.4, but the updated version fails with error Error: Cache folder path is retrieved for yarn but doesn't exist on disk in post-setup step in workflows that also run yarn install command. (We have a workflow that runs yarn audit without actually installing the dependencies. and an upgrade to v2.3/v2.4 passes there without failures.)

Our usage:

    steps:
    - name: 'Checkout'
      uses: actions/checkout@v2.3.4
    - name: 'Setup Node'
      uses: actions/setup-node@v2.4.0
      with:
        node-version: 14.x
        cache: 'yarn'

Logs from "Setup Node" step (identical for passing and failing builds):

Run actions/setup-node@v2.4.0
  with:
    node-version: 14.x
    cache: yarn
    always-auth: false
    check-latest: false
    token: ***
Found in cache @ /opt/hostedtoolcache/node/14.17.4/x64
/usr/local/bin/yarn --version
1.22.11
/usr/local/bin/yarn cache dir
/home/runner/.cache/yarn/v6
yarn cache is not found

Logs from "Post Setup Node" in successful v2.4 run:

Post job cleanup.
/usr/local/bin/yarn --version
1.22.11
/usr/local/bin/yarn cache dir
/home/runner/.cache/yarn/v6
/usr/bin/tar --posix --use-compress-program zstd -T0 -cf cache.tzst -P -C /home/runner/work/<redacted>/<redacted> --files-from manifest.txt
Cache Size: ~0 MB (258 B)
Cache saved successfully
Cache saved with the key: node-cache-Linux-yarn-abc1f1c083ff490ac797c8966c624b3975d27c522daaed7ed60b66058fca009f

Logs from "Post Setup Node" in failed v2.4 run:

Post job cleanup.
/usr/local/bin/yarn --version
1.22.11
/usr/local/bin/yarn cache dir
/home/runner/.cache/yarn/v6
Error: Cache folder path is retrieved for yarn but doesn't exist on disk: /home/runner/.cache/yarn/v6
@adrienjoly
Copy link

+1
I observed the same problem, and rolled back actions/setup-node@v2.2.0 to prevent the Cache Size: ~0 MB problem.

@jjoynsonerwin
Copy link

+1
Seeing the same issue when using version 2.4.0 with npm caching.

Post job cleanup.
/opt/hostedtoolcache/node/14.17.4/x64/bin/npm config get cache
/home/runner/.npm
Error: Cache folder path is retrieved for npm but doesn't exist on disk: /home/runner/.npm

@dmitry-shibanov
Copy link
Contributor

Hello everyone. Thank you for your report. The action on post-step fails If caching directory does not exists, that is why it has nothing to cache. The action throws an error to prevent saving empty folder.

@dmitry-shibanov dmitry-shibanov self-assigned this Aug 23, 2021
@dmitry-shibanov
Copy link
Contributor

Just a gentle ping.

@khitrenovich
Copy link
Author

Just a gentle ping.

Frankly, I was patiently waiting for a fix... Are you expecting us to do something about it? I don't think we can, since the post-step is not something the action users have any control over.

@dmitry-shibanov
Copy link
Contributor

The current behavior is expected and correct. We don't have plans to change it.

If cache is enabled in YAML and build doesn't install any dependencies - nothing to cache and cache feature won't work properly. In previous version, we skipped such errors silently but starting from 2.4.0, we have decided to fail the builds to notify users that "cache doesn't work" and user can either fix his build or disable cache.

@byrondover
Copy link

If cache is enabled in YAML and build doesn't install any dependencies - nothing to cache and cache feature won't work properly.

Doesn't this strip actions/setup-node build steps of their idempotence? That is, actions/setup-node build steps may behave differently based on the success or failure of other steps in the job, whether or not the job has been run before, and/or the results of previous jobs?

If so, I feel we may have lost something valuable here.

In previous version, we skipped such errors silently but starting from 2.4.0, we have decided to fail the builds to notify users that "cache doesn't work" and user can either fix his build or disable cache.

I personally would prefer the previous behavior, as I don't want to have to worry about whether or not setting the cache flag on actions/setup-node might cause otherwise successful jobs to fail. I get not wanting to silently swallow "cache doesn't work" issues — perhaps a clear warning in the job logs is more appropriate than a fatal error?

Here's a workaround I'm using for now, FWIW:

      # Workaround to avoid Post Use step failures. See: https://github.com/actions/setup-node/issues/317
      - run: mkdir -p /home/runner/.cache/yarn/v6
        continue-on-error: true

Appreciate your continued investment in this project, Dmitry and team! 🙇 🙏

@khitrenovich
Copy link
Author

@dmitry-shibanov Finally, I had a chance to dive a bit deeper into the issue and add some debugging to the action upgrade PR. I see that Yarn cache exists, but post-setup is unable to find it (as you can see on the screenshot below). How do you suggest to proceed with that?

image

@dmitry-shibanov
Copy link
Contributor

Hello @khitrenovich. Could you please provide repro steps or public repository ? I've tried to reproduce by my own, but it works as expected.

@khitrenovich
Copy link
Author

@dmitry-shibanov I was able to eliminate the failure after removing

env:
  FORCE_COLOR: true

setting from the job that was failing in the upgrade PR. My guess would be that the action relies on running terminal commands and parsing the output, which might be affected by the terminal settings. Removing the setting may provide a workaround, but making this a permanent limitation will be pretty inconvenient.

Here is the minimal workflow that will reproduce the issue on any Yarn-based repository:

name: Setup Node Test

on:
  workflow_dispatch:
  pull_request:

env:
  FORCE_COLOR: true

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - name: 'Checkout'
      uses: actions/checkout@v2.3.4
    - name: 'Install Node.js'
      uses: actions/setup-node@v2.4.1
      with:
        node-version: 14.x
        cache: 'yarn'
    - name: 'Install dependencies'
      run: |
        yarn install --frozen-lockfile

@dmitry-shibanov
Copy link
Contributor

Hello @khitrenovich. Thank you for your response. I think it's known problem. We had a similar issue. Please take a look and feel free to contact us if you have any questions.

@khitrenovich
Copy link
Author

Oh, good to know. Thank you for the reference!

@oscard0m
Copy link
Contributor

oscard0m commented Nov 21, 2021

Hello @khitrenovich. Thank you for your response. I think it's known problem. We had a similar issue. Please take a look and feel free to contact us if you have any questions.

Hi @dmitry-shibanov, considering this is a known problem, do you would have sense to revisit this and prevent user's using FORCE_COLOR: 1 or at least provide a warning/error message when using it? If so, I would be happy to draft a PR for it.

daniellockyer added a commit to TryGhost/Ghost that referenced this issue Nov 25, 2021
refs #13716
refs actions/setup-node#317 (comment)

- the `setup-node` GitHub Action seems to use a shell command to get the
  cache path, but these are colorised when `FORCE_COLOR` is enabled
- this causes the Action to fail to read the path correctly
- the comment referenced above suggests to remove `FORCE_COLOR` but it's
  nice to have colored output for our tests
- instead, I'm disabling the environment variable on the `setup-node`
  action so it still works
- I've tested with the referenced PR and this unblocks dependency caching 🎉
@Blackbaud-SteveBrush
Copy link

If you're using NPM (and not Yarn), I modified @byrondover's solution to make it work for our use case:

      # Workaround to avoid "Post Run actions/setup-node" failures.
      # See: https://github.com/actions/setup-node/issues/317
      - run: mkdir -p /home/runner/.npm
        continue-on-error: true

@hugovk
Copy link

hugovk commented Mar 11, 2022

Here's another workaround (thanks @daniellockyer!) TryGhost/Ghost@aec14e5

       - uses: actions/setup-node@v3
+        env:
+          FORCE_COLOR: 0

Rather than users having to disable colour output for the whole workflow (makes reading logs and diagnosing problems harder), or having to disable it for just the step as shown here, how about actions/setup-node disabling FORCE_COLOR by default, just for its own step?

mqp added a commit to manifoldmarkets/manifold that referenced this issue Nov 24, 2022
mqp added a commit to manifoldmarkets/manifold that referenced this issue Nov 24, 2022
mqp added a commit to manifoldmarkets/manifold that referenced this issue Nov 24, 2022
* Remove unused main2 merge workflow

* Pin Node version in GitHub workflows to 16, fixup caching

* Bring Node 16 @types/node up to date

* Work around a dumb bug

actions/setup-node#317
jdbocarsly added a commit to the-grey-group/datalab that referenced this issue Jan 29, 2023
ml-evs pushed a commit to the-grey-group/datalab that referenced this issue Jan 30, 2023
t3chguy added a commit to element-hq/element-desktop that referenced this issue Mar 30, 2023
jaehyeon48 added a commit to titicacadev/triple-frontend that referenced this issue Oct 6, 2023
deining pushed a commit to deining/setup-node that referenced this issue Nov 9, 2023
Bumps [husky](https://github.com/typicode/husky) from 7.0.2 to 7.0.4.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](typicode/husky@v7.0.2...v7.0.4)

---
updated-dependencies:
- dependency-name: husky
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants