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

FORCE_COLOR=true causes "Cache folder path is retrieved for yarn but doesn't exist on disk" #772

Closed
2 of 5 tasks
bencochran opened this issue Jun 3, 2023 · 4 comments
Closed
2 of 5 tasks
Assignees
Labels
bug Something isn't working

Comments

@bencochran
Copy link

bencochran commented Jun 3, 2023

Description:

tl;dr: FORCE_COLOR=true in build environment causes yarn cache dir output to be prefixed with "\u001b[2K\u001b[1G" which gets pulled in as cachePath, which definitely doesn’t fs.existsSync.

Workaround at the end if google leads you here before this is fixed.

The story version:
I kept having failures on “Post Run actions/setup-node@v3” on a seemingly minimal yarn action:

on: [push, pull_request]

env:
  FORCE_COLOR: true

jobs:
  test:
    name: test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-node@v3
      with:
        node-version: 18
        cache: 'yarn'
    - run: yarn install --frozen-lockfile
    - run: yarn test

The failure I was getting:

Error: Cache folder path is retrieved for yarn but doesn't exist on disk: /home/runner/.cache/yarn/v6

I connected to the worker to poke around… that directory was indeed there. I try fs.existSyncing the directory myself from node, thinking it’s something wacky with permissions… works fine.

Well… it turns out the cachePath is \u001b[2K\u001b[1G/home/runner/.cache/yarn/v6 with some pesky ANSI control characters hanging around. Copy-pasting it works just fine but, of course, those characters are in the js string.

yarn cache dir itself seems to throw those in to erase the entire line and move the cursor to the first column. Thanks, yarn.

Action version:

3.4.1

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

  • node: 18.16.0
  • yarn: 1.22.19

Repro steps:

Minimal repro repo: https://github.com/bencochran/setup-node-assi-escape-code-bug

Or:

  1. Enable yarn caching
- uses: actions/setup-node@v3
  with:
    node-version: current
    cache: 'yarn'
  1. Add FORCE_COLOR=true
env:
  FORCE_COLOR: true

Expected behavior:

I expect the cache to work. And not fail the job.

Actual behavior:

The cache doesn't work and the job fails at the post-step action with the following:

Post Run actions/setup-node@v3” 

Post job cleanup.
/usr/local/bin/yarn --version
1.22.19
/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

Workaround:

Remove FORCE_COLOR or move the env into a specific step like:

on: [push, pull_request]

jobs:
  test:
    name: test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-node@v3
      with:
        node-version: current
        cache: 'yarn'
    - run: yarn install --frozen-lockfile
      env:
        FORCE_COLOR: true
    - run: yarn test
@bencochran bencochran added bug Something isn't working needs triage labels Jun 3, 2023
@dusan-trickovic
Copy link

Hello, @bencochran ! Thank you for reporting the issue, we will take a look at it and see what can be done :)

@dmitry-shibanov
Copy link
Contributor

Hello @bencochran. Could you please try to use the snippet from this comment: #317 (comment)

@bencochran
Copy link
Author

bencochran commented Jun 5, 2023

Thanks pointing me to that, @dmitry-shibanov. That also makes it work. Embarrassingly, I did see that issue, but didn’t read deep enough into the comments to find that it came down to the same issue. Sorry about the dupe!

@dmitry-shibanov dmitry-shibanov self-assigned this Jun 22, 2023
@dmitry-shibanov
Copy link
Contributor

Hello @bencochran. Sorry for the late response. For now I'm going to close the issue because it can be fixed by FORCE_COLOR: 0 for action step. Besides, I think it can be fixed in scope of the action because it gets applied to the command output.

@dmitry-shibanov dmitry-shibanov closed this as not planned Won't fix, can't repro, duplicate, stale Jun 22, 2023
davidfestal added a commit to davidfestal/backstage-plugins that referenced this issue Sep 25, 2023
actions/setup-node#772
Signed-off-by: David Festal <dfestal@redhat.com>
davidfestal added a commit to davidfestal/backstage-plugins that referenced this issue Sep 25, 2023
This was due to the following bug:
actions/setup-node#772

Signed-off-by: David Festal <dfestal@redhat.com>
davidfestal added a commit to janus-idp/backstage-plugins that referenced this issue Sep 25, 2023
chore(ci): fix a CI error in setup-node

This was due to the following bug:
actions/setup-node#772

Signed-off-by: David Festal <dfestal@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants