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

[Bug] running patch-commit for a package that has a builtin patch fails #4441

Open
merceyz opened this issue May 6, 2022 · 4 comments
Open
Labels
bug Something isn't working upholded Real issues without formal reproduction

Comments

@merceyz
Copy link
Member

merceyz commented May 6, 2022

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 #4218 (comment)

@merceyz merceyz changed the title Running patch-commit for a package that has a builtin patch now fails with [Bug] running patch-commit for a package that has a builtin patch fails May 6, 2022
@merceyz merceyz added bug Something isn't working upholded Real issues without formal reproduction labels May 6, 2022
@oxc
Copy link

oxc commented Oct 13, 2022

I can confirm this for typescript 4.8.4.

yarn 3.2.3 with nodeLinker: node-modules

@Deco
Copy link

Deco commented Dec 4, 2022

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.

@mrflip
Copy link

mrflip commented May 10, 2023

Any fix to this? I was able to limp the patch command home (I think) by supplying the resolution stanza myself:

  "resolutions": {
    "typescript@5.0.4": "patch:typescript@5.0.4#.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.

@mrflip
Copy link

mrflip commented May 10, 2023

More headbanging found a workaround.

  1. 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 like node_modules/typescript/<stuff>)
  2. visit the node_modules/typescript directory (the one with a package.json) and run touch ./yarn.lock
  3. run yarn pack --out ../../../path/to/desired/location/of/package/typescript-munged.tar.gz
  4. back in your project root, run yarn add typescript@file:./...relative path.../typescript-munged.tar.gz
  5. you will see yarn take your munged version of the package and apply its own magic patches.

This seems to have done the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upholded Real issues without formal reproduction
Projects
None yet
Development

No branches or pull requests

4 participants