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

yarn cache saving nothing #407

Closed
mmahalwy opened this issue Aug 3, 2021 · 3 comments
Closed

yarn cache saving nothing #407

mmahalwy opened this issue Aug 3, 2021 · 3 comments
Labels
type: enhancement New feature or request

Comments

@mmahalwy
Copy link

mmahalwy commented Aug 3, 2021

In the logs:

##[debug]implicitDescendants 'false'
##[debug]followSymbolicLinks 'true'
##[debug]implicitDescendants 'false'
##[debug]omitBrokenSymbolicLinks 'true'
##[debug]Search path '/github/home/.cache/yarn'
##[debug]Cache Paths:
##[debug][]
##[debug]Archive Path: /__w/_temp/07a15199-21c2-43ce-8c0a-cc01882a0843/cache.tgz
/bin/tar --posix -z -cf cache.tgz -P -C /__w/brooklyn/brooklyn --files-from manifest.txt
/bin/tar -z -tf /__w/_temp/07a15199-21c2-43ce-8c0a-cc01882a0843/cache.tgz -P
##[debug]File Size: 45
##[debug]Saving Cache (ID: 69)
##[debug]Upload cache
##[debug]Resource Url: https://artifactcache.actions.githubusercontent.com/fmfATEajpiOCSHwAtp7sjR8AAEAsY7yLnCJarOtkklYPFr9aLe/_apis/artifactcache/caches/69
##[debug]Upload concurrency: 4
##[debug]Upload chunk size: 33554432
##[debug]Awaiting all uploads
##[debug]Uploading chunk of size 45 bytes at offset 0 with content range: bytes 0-44/*
##[debug]Commiting cache
Cache Size: ~0 MB (45 B)
##[debug]Resource Url: https://artifactcache.actions.githubusercontent.com/fmfATEajpiOCSHwAtp7sjR8AAEAsY7yLnCJarOtkklYPFr9aLe/_apis/artifactcache/caches/69
Cache saved successfully

I am noticing that subsequent runs are hitting cache but cache is empty. Probably this is pointing at the wrong paths for yarn. see:

o.inputPath = path.join(homeDirectory, '.cache', 'yarn')
when it should point at whatever yarn cache dir returns?

@mmahalwy
Copy link
Author

mmahalwy commented Aug 3, 2021

I've found the way to fix it is to add

- run: yarn config set cache-folder ~/.cache/yarn

That way it matches what is in the code.

@forgo
Copy link

forgo commented Sep 28, 2021

I've found the way to fix it is to add

- run: yarn config set cache-folder ~/.cache/yarn

That way it matches what is in the code.

These issues seem to be tangentially related: #430

This workaround is not really a solution if you are leveraging Zero-Installs and using the --immutable --immutable-cache options in the CI install step ahead of Cypress.

If I try the workaround mentioned above (using yarn2 syntax) before my install step:

      # Change Yarn Cache folder to match expectation of cypress-io/github-action@v2
      # https://github.com/cypress-io/github-action/issues/407
      - name: Change Yarn Cache Folder for Cypress GitHub action Bug Workaround
        run: yarn config set cacheFolder ~/.cache/yarn

Then, I'll get this error:

Run yarn install --immutable --immutable-cache
Internal Error: Cache path does not exist.

Locally, if you run this in the project, you'll see that it's adding the following line to the .yarnrc.yml:

cacheFolder: /Users/forgo/.cache/yarn

If you dig into the yarn code, you'll see this:
https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Cache.ts#L131

With Zero-Installs, most projects will be checking in their entire cache directory: <projectRoot>/.yarn/cache -- which doesn't match the expected path you mentioned ~/.cache/yarn within the context of this GitHub action.

To fix this, I believe there needs to be a way for inputPath to be configurable OR to default to to the yarn (berry) cache directly. Possibly a flag that enables yarnZeroInstalls: true to get this out-of-the-box.

What are your thoughts?

@MikeMcC399
Copy link
Collaborator

See also the updated README > Yarn Modern which discusses how to run Yarn Modern including a workaround for Yarn Plug'n'Play.

@MikeMcC399 MikeMcC399 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants