You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cache: yarn not working for Yarn 3 (Berry) in a subfolder #488
actions/setup-node correctly launches the right version of Yarn (which is included into the repo). Therefore, the right folder is cached and the follow-up setup is faster.
Actual behavior:
Yarn cache dir is resolved to /home/runner/.cache/yarn/v6. This is because yarn --version is called in the default directory, which is followed by yarn cache dir instead of yarn config get cacheFolder inside tooling. Cache end up empty and so all packages are re-downloaded again each time.
Potential solution:
It’d be nice to pass working-directory down to actions/setup-node (similar to the run task).
Thanks for your issue. This is unexpected behavior because you're using binaries located directly in a directory, but the action is running at the root of the repository, so it doesn't see yarn binaries in a subfolder. So the yarn version hasn't changed.
We recommend that you install the required version before restoring the cache.
This is unexpected behavior because you're using binaries located directly in a directory, but the action is running at the root of the repository
Yep, that's what happens. Keeping Yarn binary in the project and calling global yarn is a normal thing for Yarn berry. In this case global yarn command finds a local binary and delegates everything to it. Thus, there is no need install the right version of global yarn to get the right behavior.
Running yarn config get cacheFolder returns [project-dir]/.yarn/cache rather than some shared global folder. Even if I install the ‘right’ global Yarn but call it from a wrong cwd, it won't return the correct result. Thus, as far as I understand, the only solution is to have something like:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- cache-dependency-path: tooling/yarn.lock+ working-directory: tooling ## proposed option, does not exist at the time of writing
This proposed working-directory option will help find yarn.lock path, so cache-dependency-path won't be necessary. This will also make global yarn delegate everything to [job-dir]/tooling/.yarn/releases/yarn-3.x.x.cjs. The delegated binary will know the right cacheFolder: [job-dir]/tooling/.yarn/cache.
Please let me know if you see other solutions here! 🙂
Reacted by Spenser Black, subash adhikari, Daniel Hoffmann Bernardes, Yuku Takahashi and Kevin Hu
Hi, @kachkaev 👋 ! Thanks for popping this issue up! Our action, in fact, doesn't support yarn berry out of the box, but you found the perfect workaround that can be helpful to other customers! I think we can close this issue now because it's not really a bug, but expected behaviour. However, I'd like to ask you to open a new feature request and we will investigate the possibility of adding this functionality to the new releases.
👋 @IvanZosimov! Yeah I actually agree with you that this more like a feature request rather than a bug report. Do you know if it’s OK to just change issue labels instead of closing and reopening it?
Hello @kachkaev, i am going to close this issue because the PR is merged , but please feel free to reopen it or create new issue in case if the problem still exists
Activity
e-korolevskii commentedon May 11, 2022
Hi @kachkaev ,
We will investigate on that issue and come back to you.
e-korolevskii commentedon May 18, 2022
Hello @kachkaev ,
Thanks for your issue. This is unexpected behavior because you're using binaries located directly in a directory, but the action is running at the root of the repository, so it doesn't see yarn binaries in a subfolder. So the yarn version hasn't changed.
We recommend that you install the required version before restoring the cache.
kachkaev commentedon May 18, 2022
Yep, that's what happens. Keeping Yarn binary in the project and calling global
yarnis a normal thing for Yarn berry. In this case globalyarncommand finds a local binary and delegates everything to it. Thus, there is no need install the right version of globalyarnto get the right behavior.Running
yarn config get cacheFolderreturns[project-dir]/.yarn/cacherather than some shared global folder. Even if I install the ‘right’ global Yarn but call it from a wrongcwd, it won't return the correct result. Thus, as far as I understand, the only solution is to have something like:- name: Setup Node uses: actions/setup-node@v3 with: node-version: 18 cache: yarn - cache-dependency-path: tooling/yarn.lock + working-directory: tooling ## proposed option, does not exist at the time of writingThis proposed
working-directoryoption will help findyarn.lockpath, socache-dependency-pathwon't be necessary. This will also make globalyarndelegate everything to[job-dir]/tooling/.yarn/releases/yarn-3.x.x.cjs. The delegated binary will know the rightcacheFolder:[job-dir]/tooling/.yarn/cache.Please let me know if you see other solutions here! 🙂
IvanZosimov commentedon May 25, 2022
Hi, @kachkaev 👋 ! Thanks for popping this issue up! Our action, in fact, doesn't support yarn berry out of the box, but you found the perfect workaround that can be helpful to other customers! I think we can close this issue now because it's not really a bug, but expected behaviour. However, I'd like to ask you to open a new feature request and we will investigate the possibility of adding this functionality to the new releases.
kachkaev commentedon May 25, 2022
👋 @IvanZosimov! Yeah I actually agree with you that this more like a feature request rather than a bug report. Do you know if it’s OK to just change issue labels instead of closing and reopening it?
IvanZosimov commentedon May 26, 2022
Hello, @kachkaev 👋 ! Yes, it's OK, I changed the label by myself, thank you again for contributing 🤟
10 remaining items
workaround for yarn caches on subprojects: from actions/setup-node#48…
workaround for yarn caches on subprojects: from actions/setup-node#48…
Release 2.0.1 (#95)
Release 2.0.2 (#96)
update gh-pages commands (#98)
gh-pages (#100)
danialdezfouli commentedon Mar 13, 2023
I fixed it with the following setup, but the docker still takes time (2-3m) to build the image, maybe we should apply cache to docker too.
Release 2.0.2 (#101)
Merge branch 'develop'
extend setup-node with proper yarn 3 caching
dsame commentedon Jul 25, 2023
Hello @kachkaev, i am going to close this issue because the PR is merged , but please feel free to reopen it or create new issue in case if the problem still exists
chore(deps-dev): bump typescript from 4.9.5 to 5.0.2 (actions#488)
More website fixes (#672)
Update actions/setup-node action to v4 (#56)