berry: [Bug?]: yarn workspaces focus command fails in ^3.0.0-rc
Self-service
- I’d be willing to implement a fix
Describe the bug
When running the command yarn workspaces focus <pkg>
in 3.0-rc versions
Type Error: e.every is not a function
at test (/frontend/.yarn/releases/yarn-3.0.0-rc.9.cjs:10:36984)
To reproduce
const path = require(`path`);
const {promises: {mkdir, readFile, writeFile, writeJson}} = require(`fs`);
await packageJsonAndInstall({
"name": "root",
"private": true,
"workspaces": [
"packages/*"
]
});
/* create an app module*/
await mkdir('packages/lib', { recursive: true });
await writeFile("packages/lib/package.json", `{
"peerDependencies": {
"lodash": "^4.0.0"
},
"main": "index.js",
"name": "lib",
"version": "0.0.1"
}`);
const version = await yarn('--version');
console.log('version', version);
await yarn(`install`);
await expect(yarn(`workspaces`, `focus`, `lib`)).rejects.not.toThrow();
Environment
System: OS: macOS 11.4 CPU: (4) x64 Intel® Core™ i5-7500 CPU @ 3.40GHz Binaries: Node: 14.2.0 Yarn: 3.0.0-rc.9
Additional context
It seems to be throwing from the typanion
package
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 23 (6 by maintainers)
Commits related to this issue
- Make Type Check In `validateAndExecute()` Stricter We were seeing an issue in yarn v3.0.2 when using the workspaces plugin where it was possible for a command's `schema` prop to be not `undefined`, b... — committed to noseworthy/clipanion by noseworthy 3 years ago
- Make Type Check In `validateAndExecute()` Stricter We were seeing an issue in yarn v3.0.2 when using the workspaces plugin where it was possible for a command's `schema` prop to be not `undefined`, b... — committed to noseworthy/clipanion by noseworthy 3 years ago
- Make Type Check In `validateAndExecute()` Stricter (#102) We were seeing an issue in yarn v3.0.2 when using the workspaces plugin where it was possible for a command's `schema` prop to be not `unde... — committed to arcanis/clipanion by noseworthy 3 years ago
You need to update the plugins you’re using as well when you update the CLI
The specific fix for this:
Highly recommend running the same for all your plugins listed in your
.yarnrc.yml
Just wanted to add another experience of this issue. After updating yarn to 3.2.x in our monorepo, all
workspace foreach
commands worked as expected locally but three of them failed on CI.Based on some of the very helpful description in this comment, we were able to deduce that the arguments to the
workspaces foreach
was the cause of the issue.Yeah, I’m talking specifically about the cache available in gitlab runners: https://docs.gitlab.com/ee/ci/caching/. We had configured the runner to zip up the whole
.yarn/
directory and send it off to a blob storage. Then when the next job of that type ran, after git checkout, it downloaded and unzipped the “cache” from the blob store. There’s no cache key really. Sort of a blunt instrument. We just disabled the whole thing.yarn
’s zero install stuff is better and we hadn’t really been using it since we switched over toberry
and started really using the zero install stuff. So it was just dirtying up the workspace and taking time and energy zipping up, pushing, and pulling archives that were totally useless. 🤦♂️@noseworthy Aha, thank you! Bad cache invalidation turned out to be my issue as well! I’ve added
.yarnrc.yml
to my cache paths so the old cache will get invalidated properly next time on new Yarn releases. Now everything is working great both locally and on Github Actions! I’m good with this ticket being closed out! Thank you everyone for your time!Hey @merceyz! Thanks for re-opening. I’ve been trying to reproduce all day so I could get that to you, but unfortunately I was only able to reproduce with v2 plugins as you said. However on our CI/CD system running on GitLab pipelines this failed every time for our
main
branch.After a whole bunch of debugging we’ve discovered that it was some caching that we were doing in the pipeline that was causing this to fail. We were caching the
.yarn/
directory and re-using it between builds. The order of operations in our pipelines was:Since
.yarn/
was in our cache and the plugins use the same file name regardless of version, we ended up checking out the v3 plugins, then immediately overwriting them every time with the old v2 plugins. We’ve since fixed up our caching strategy and everything works as expected now on our end. Sorry for the noise on this one, though it does seem that @jalovatt and @davidcalhoun are still experiencing issues. Maybe this little post-mortem helps?Thanks again for your work on this project. Yarn is wonderful ❤️
Hey, @merceyz and @AlexandreBonaventure! Since it seems like this issue isn’t resolved. Should this issue be re-opened or should I create a new issue? Is there any extra information that would be helpful? Thanks for your work on this project!
Nope. We’re sticking to v2 for the moment.
I’m seeing the same error in our CI on 3.0.1 even after updating my plugins. It works when run locally, though. 😕