-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Bug]: Yarn patches are not applied for deps using resolutions
#4231
Comments
That's odd but when a patch is updated there should be a change to the lockfile which would invalidate the cache. |
I actually spoke too soon. Busting the cache doesn't fix the problem, and a fresh install doesn't seem to be patching either in CI. I'm looking into other issues. |
I also tried removing the cache entirely and the files are still not patched in CI. This is very confusing. |
For example, this is the pre-patched code that fails: if (opts.platforms) {
// @ts-ignore
platforms = (0, _lodash().pick)(platforms, opts.platforms);
_cliTools().logger.debug('Skipping selected platforms');
}
_cliTools().logger.debug('Available platforms: ' + `${Object.keys(platforms).map(_getPlatformName.default).join(', ')}`);
if (rawPackageName === undefined) {
_cliTools().logger.debug('No package name provided, will link all possible assets.');
return (0, _linkAll.default)(ctx, {
linkDeps: opts.all,
linkAssets: true
});
} The
And this is our patch:
And the patch applied to the code locally: if (opts.platforms) {
// @ts-ignore
platforms = (0, _lodash().pick)(platforms, opts.platforms);
// We filter down the platforms but dont apply it to the context,
// which results in ios still being targeted elsewhere.
ctx.platforms = platforms;
_cliTools().logger.debug('Skipping selected platforms');
}
_cliTools().logger.debug('Available platforms: ' + `${Object.keys(platforms).map(_getPlatformName.default).join(', ')}`);
if (rawPackageName === undefined) {
_cliTools().logger.debug('No package name provided, will link all possible assets.');
return (0, _linkAll.default)(ctx, {
linkDeps: opts.all,
linkAssets: true
});
} Line 82 is no longer Yet after all this, CI is still failing with the original error. Is it possible for the patches to not be applied and failures to not be bubbled up? |
One piece of context that may be useful is that this is running in a docker container. |
So in CI I went ahead and |
I also noticed that the lockfile isn't showing the patch defined in So But this still doesn't explain why it works locally and not in CI. |
It's very difficult to understand what might happen without a reproduction, unfortunately. We use patches at work without issues, so there's something very specific to your context - if we can't isolate what that is, we can't help you much 🙁 |
@arcanis Yeah I figured. Creating a reproduction will be impossible. Does Yarn have any kind of debugging I can enable or something? |
Enabled
We have a resolution entry for typescript, so we only have the 1 version. |
@arcanis @merceyz Tried another repo, same problem. Had teammates test patches and they report it also not patching, even locally. So I created a simple repo as a test case and the patch still is not applied, even locally: https://github.com/milesj/yarn-patch-transient-deps We tried Yarn 3.2 and 3.1 and both failed. This looks to be a legitimate bug in Yarn. EDIT: Confirmed patching works for explicit deps ( Works: "devDependencies": {
"@react-native-community/cli": "patch:@react-native-community/cli@npm:^6.4.0#../../.yarn/patches/@react-native-community-cli-npm-6.4.0-f99ee73e09",
} Does not work: "devDependencies": {
"@react-native-community/cli": "^6.4.0"
},
"resolutions": {
"@react-native-community/cli": "patch:@react-native-community/cli@npm:^6.4.0#../../.yarn/patches/@react-native-community-cli-npm-6.4.0-f99ee73e09",
} Also does not work (transitive dep): "resolutions": {
"@react-native-community/cli": "patch:@react-native-community/cli@npm:^6.4.0#../../.yarn/patches/@react-native-community-cli-npm-6.4.0-f99ee73e09",
} |
resolutions
resolutions
resolutions
This particular problem is known (and fixed, once #4218 is merged). The To fixes that, just replace: "resolutions": {
"@react-native-community/[email protected]": "patch:..."
} By: "resolutions": {
"@react-native-community/cli@^6.0.0": "patch:..."
} Another option is to remove the range altogether, in which case all instances of "resolutions": {
"@react-native-community/cli": "patch:..."
} |
That... makes sense in retrospect. Will give that a try again on Monday. Although the PR is improving patches, it would be nice if Yarn would warn if there's a patch that doesn't get applied for some reason. |
Tested and works 👍 Thanks for the info and reading my rambling. |
I'm still experiencing this issue and adding |
* chore: maybe we are now 100% browser compitible? * chore: why is everything broken permalink: http://whatthecommit.com/61392d8529ad51956024f721ebf30995 * chore: epic permalink: http://whatthecommit.com/d9796047a759e445935a287c17d1037c * chore: is there an award for this? permalink: http://whatthecommit.com/cb4f7f1124e8bd95fc10f272830701d3 * ci: push unfinished test * chore: merge pull my finger request permalink: http://whatthecommit.com/569aa58b98f6e4aac466357a4997c2b2 * ci: do in correct way * ci: fix scripts and build once * ci: skip lib check bcz of happy-dom typings * ci: change name * test: fix file path * chore: use jsdom * chore: it worked * ci: change test as vitest is weired * chore: remove script * chore: fix pc load letter error permalink: http://whatthecommit.com/43398194a4cdd602ab7456be8066106f * chore: reinventing the wheel. again. permalink: http://whatthecommit.com/b2b30ca13c6041aee39eecb2b3a47211 * chore: readd `node:` protocol with a patch * chore: it worked yarnpkg/berry#4231 Co-authored-by: Jeroen Claassens <[email protected]>
I also faced this issue today, can confirm that the |
@arcanis if mine is a duplicate of this, and this is closed, and mine happened today on the latest release, how can this be fixed/closed? |
Because it's in RCs for the next 4.x major, not in 3.x patches. |
It's a bug fix so why it's not coming in 3x? |
Could this be Cherry picked back to 3.x please? |
I'm still experiencing issues with my patch resolution on 4.0.0-rc.14. These were the resolutions generated by patch-commit on 3.x:
Edit: As per #4711 (comment), this worked:
|
Yes this is is still very annoying. Anytime we use patches, they don't work immediately, and we constantly have to tinker with the resolution version to get them working. A fix in a release would be much appreciated. |
When will this fix be released on the stable branch? |
The fix has been released in v3.2.3 |
I am using yarn v3.3.1 and it didn't work for me. |
Same here... |
I'm on yarn 3.2.3 and was having this issue where the patches would only be applied on first install, but would not work on subsequent I fixed it by changing the resolutions added by yarn automatically from this:
To this:
Notice the unescaping of the colon after Now the patch gets correctly applied every time! |
I made the above change and found similar resolution higher up that was problematic in my case. Although for me the problem was it not applying all the patches, just some of them. Anyway, hope this helps... "resolutions": {
"@types/react": "17.0.2",
"@types/react-dom": "17.0.2",
"@aries-framework/core": "0.3.3",
...
"@aries-framework/[email protected]": "patch:@aries-framework/core@npm:0.3.3#./.yarn/patches/@aries-framework-core-npm-0.3.3-dd6486de3d.patch",
} I had to remove |
We hadn't updated to |
just encountered this with the most recent yarn 4.0.2. After fiddling with package resolutions the patch was applied on production, but still could not see it on staging CI, very weird. No error messages either. Initial package.json: "@uppy/compressor": "patch:@uppy/compressor@npm%3A1.0.5#~/.yarn/patches/@uppy-compressor-npm-1.0.5-c6622da068.patch",
What worked: "@uppy/compressor": "patch:@uppy/compressor@npm:^1.0.5#../../../../.yarn/patches/@uppy-compressor-npm-1.0.5-c6622da068.patch", (unescaped yarn.lock: "@uppy/compressor@npm:^1.0.5":
version: 1.0.5
resolution: "@uppy/compressor@npm:1.0.5"
dependencies:
"@transloadit/prettier-bytes": "npm:^0.0.9"
"@uppy/utils": "npm:^5.5.2"
compressorjs: "npm:^1.1.1"
preact: "npm:^10.5.13"
promise-queue: "npm:^2.2.5"
peerDependencies:
"@uppy/core": ^3.6.0
checksum: bd550351845b5d75daaf7f9626dce2f49a4c9a51dd9e665e05b2748ae8fd4d4f83c5973ec7aed43df9eea5053264f9bec3e167a622228f038b7a6dd4d341e298
languageName: node
linkType: hard
"@uppy/compressor@patch:@uppy/compressor@npm:^1.0.5#../../../../.yarn/patches/@uppy-compressor-npm-1.0.5-c6622da068.patch::locator=vue%40workspace%3Afront%2Fweb_server%2Fwww%2F_vue":
version: 1.0.5
resolution: "@uppy/compressor@patch:@uppy/compressor@npm%3A1.0.5#../../../../.yarn/patches/@uppy-compressor-npm-1.0.5-c6622da068.patch::version=1.0.5&hash=58663d&locator=vue%40workspace%3Afront%2Fweb_server%2Fwww%2F_vue"
dependencies:
"@transloadit/prettier-bytes": "npm:^0.0.9"
"@uppy/utils": "npm:^5.5.2"
compressorjs: "npm:^1.1.1"
preact: "npm:^10.5.13"
promise-queue: "npm:^2.2.5"
peerDependencies:
"@uppy/core": ^3.6.0
checksum: a79efe83d7bf503551f5d293569d094438d7b62cb7941624687f9100a240936debf5a84016c8348f2e8e8f1db66da8d8b17628a22ee349910bdfae5b9fef3075
languageName: node
linkType: hard
|
Self-service
Describe the bug
Short: Yarn patches (
.yarn/patches
) are not applied when node modules are restored from a cache (ignores the fetch step).Long: In CI, we cache the
.yarn/cache
and.yarn/install-state.gz
files based on the checksum ofyarn.lock
. This works pretty great and reduces the "fetch step" duringyarn install
down to 1 second. Overall, the entirety of yarn install takes less than 2 minutes (most of it is linking).However, we've noticed the new patches do not get applied when we use this approach, while patches work locally. This is very apparent because builds crash in CI that were fixed by this patch, and the line numbers in the stack trace are pointing to the original pre-patch lines.
Since we have no way to apply patches manually, I'm not sure how to work around this. Busting the cache didn't work. And also caching
.yarn/patches
didn't work.To reproduce
Our problem is unique to Buildkite CI but it can maybe be replicated with GitHub actions: https://github.com/actions/setup-node
Environment
Additional context
We're using Buildkite with the cache plugin:
The text was updated successfully, but these errors were encountered: