[Bug] running `patch-commit` for a package that has a builtin patch fails
Running patch-commit for a package that has a builtin patch now fails with
Internal Error: Assertion failed: Expected the resolution to have been registered
at PatchCommitCommand.execute (/berry/packages/plugin-patch/sources/commands/patchCommit.ts:82:15)
at PatchCommitCommand.validateAndExecute (/berry/.yarn/__virtual__/clipanion-virtual-6f45223597/0/cache/clipanion-npm-3.2.0-rc.4-8470d16306-c9d8ba9e16.zip/node_modules/clipanion/lib/advanced/Command.js:67:26)
at Cli.run (/berry/.yarn/__virtual__/clipanion-virtual-6f45223597/0/cache/clipanion-npm-3.2.0-rc.4-8470d16306-c9d8ba9e16.zip/node_modules/clipanion/lib/advanced/Cli.js:149:24)
at Cli.runExit (/berry/.yarn/__virtual__/clipanion-virtual-6f45223597/0/cache/clipanion-npm-3.2.0-rc.4-8470d16306-c9d8ba9e16.zip/node_modules/clipanion/lib/advanced/Cli.js:158:28)
at exec (/berry/packages/yarnpkg-cli/sources/main.ts:148:7)
at run (/berry/packages/yarnpkg-cli/sources/main.ts:48:7)
Originally posted by @merceyz in https://github.com/yarnpkg/berry/issues/4218#issuecomment-1072905294
I can confirm this for typescript 4.8.4.
yarn 3.2.3 with nodeLinker: node-modules
I can confirm this for TypeScript 4.9.3 on Yarn 3.3.0 with nodeLinker: node-modules.
I tried both yarn patch typescript@npm:4.9.3 and yarn patch "typescript@patch:typescript@npm%3A4.9.3#~builtin<compat/typescript>::version=4.9.3&hash=d73830". Neither would successfully commit.
Any fix to this? I was able to limp the patch command home (I think) by supplying the resolution stanza myself:
"resolutions": {
"[email protected]": "patch:[email protected]#.yarn/patches/typescript-npm-5.0.4-122f6a883a.patch"
},
but nothing happens when I yarn install, because I think either the builtin-compat one is not being patched or it won't do multiple patches or something. I tried applying my patch to the patched zip, but I don't know how to calculate the checksup to cheat it home. I think that I can't use ts from a git repo because I'll need the yarn patches applied
Any advice on how to arm-twist yarn into applying these changes welcome.
More headbanging found a workaround.
- expand the base package zip -- in this case
.yarn/cache/typescript-npm-5.0.4-122f6a883a-82b94da3f4.zip-- and unzipped it to a directory (paths looked likenode_modules/typescript/<stuff>) - visit the node_modules/typescript directory (the one with a package.json) and run
touch ./yarn.lock - run
yarn pack --out ../../../path/to/desired/location/of/package/typescript-munged.tar.gz - back in your project root, run
yarn add typescript@file:./...relative path.../typescript-munged.tar.gz - you will see yarn take your munged version of the package and apply its own magic patches.
This seems to have done the trick.
This will happen all the time when there's an entry for the package in resolutions itself - seems some bugs in that.
Also happens when you already have a custom patch for a package and try to add an additional patch via yarn patch --update dom-to-image and yarn patch-commit -s /tmp/xfs-9bd1beff/user.
any resolution to this problem?