Berry: [Bug] Typescript 3.6.5 installation failure (cannot apply hunk)

Created on 20 Apr 2020  Â·  15Comments  Â·  Source: yarnpkg/berry

Installing typescript 3.6.5 fails when applying compat patch.

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 1.29s
➤ YN0000: ┌ Fetch step
➤ YN0013: │ typescript@patch:typescript@npm%3A3.6.5#builtin<compat/typescript>::version=3.6.5&hash=c79188 can't be found in the cache and will be fetched from the disk
➤ YN0001: │ Error: typescript@patch:typescript@npm%3A3.6.5#builtin<compat/typescript>::version=3.6.5&hash=c79188: Cannot apply hunk #5
    at c (/tmp/berry-test-ts3.6/.yarn/releases/yarn-berry.js:56:59007)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async /tmp/berry-test-ts3.6/.yarn/releases/yarn-berry.js:56:61149
    at async o (/tmp/berry-test-ts3.6/.yarn/releases/yarn-berry.js:56:58290)
    at async Object.t.applyPatchFile (/tmp/berry-test-ts3.6/.yarn/releases/yarn-berry.js:56:61122)
    at async t.PatchFetcher.patchPackage (/tmp/berry-test-ts3.6/.yarn/releases/yarn-berry.js:56:58045)
    at async /tmp/berry-test-ts3.6/.yarn/releases/yarn-berry.js:56:57194
    at async d (/tmp/berry-test-ts3.6/.yarn/releases/yarn-berry.js:42:91814)
    at async /tmp/berry-test-ts3.6/.yarn/releases/yarn-berry.js:42:92398
    at async /tmp/berry-test-ts3.6/.yarn/releases/yarn-berry.js:42:93503
➤ YN0000: └ Completed in 14.5s
➤ YN0000: Failed with errors in 15.79s

The same error occurs for the whole 3.6.x series. 3.5 installs correctly, so does 3.7.

Installing yarn from sources doesn't help.

For context, this happened while installing @angular-devkit/[email protected].

Reproduction:

$ mkdir repro
$ cd repro
$ yarn set version berry
$ yarn init
$ yarn add [email protected]

Env (linux)

$ yarn --version
2.0.0-rc.32
$ node --version
v12.16.1
bug upholded

All 15 comments

Got something similar:

➤ YN0000: └ Completed in 1.46m
➤ YN0000: ┌ Fetch step
➤ YN0013: │ typescript@patch:typescript@npm%3A3.6.5#builtin<compat/typescript>::version=3.6.5&hash=c79188 can't be found in the cache and will be fetched from the disk
➤ YN0001: │ Error: typescript@patch:typescript@npm%3A3.6.5#builtin<compat/typescript>::version=3.6.5&hash=c79188: Cannot apply hunk #5
    at c (/Users/dev/Projects/GitHub/storybook/core/.yarn/releases/yarn-2.0.0-rc.32.js:56:59007)
    at process._tickCallback (internal/process/next_tick.js:68:7)
➤ YN0000: └ Completed in 11.19s
➤ YN0000: Failed with errors in 1.65m

Thanks, also ran into this. 3.8 seems to work.

Hi! 👋

This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).

Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolution faster). It helps us help you! 😃

If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label.

I was able to go around this issue by pinning down typescript resolutions in package.json

{
  // ...
  "resolutions": {
     "typescript": "3.9.5"
  }
}

May not work for all but should work for most.

Looks like typescript 3.9.5 works for me... sometimes.
In one of my projects it works, I see

typescript@patch:typescript@npm%3A3.9.5#builtin<compat/typescript>::version=3.9.5&hash=8cac75

In a different project yarn install is failing with message

typescript@patch:typescript@npm%3A3.9.5#builtin<compat/typescript>::version=3.9.5&hash=270b6c: Cannot apply hunk #6

I don't know why a different hash is being used for the same typescript major minor patch semver even after I clear the cache and remove the lockfile for both projects. Weird.

Do you have the same yarn version in both projects? Yarn patches typescript to add support for PnP.

trying to install
"@angular-devkit/build-angular": "~0.901.4",
causes this because it depends on 3.6.5, there's no resolution that will work because 3.6.5 is the final 3.6 version.. how does something like this sneak in? this patch system seems flawed.... I'm not even using PnP

Do you have the same yarn version in both projects? Yarn patches typescript to add support for PnP.

I hadn't thought about checking. Looks like the Cannot apply hunk #6 was when I was using yarn 2.0.0-rc.31, however the projects which were not failing used more recent versions.

Upgraded yarn via yarn set version latest and then install worked fine w/ typescript 3.9.5.

node v10.21.0 & v11.15.0

➤ YN0001: │ Error: typescript@patch:typescript@npm%3A3.6.5#builtin<compat/typescript>::version=3.6.5&hash=64df9d: Cannot apply hunk #6
     at C (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:77:103081)

node v12.18.2 & v13.14.0 & v14.5.0

➤ YN0001: │ Error: typescript@patch:typescript@npm%3A3.6.5#builtin<compat/typescript>::version=3.6.5&hash=64df9d: Cannot apply hunk #6
    at C (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:77:103081)
    at async /home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:77:102344
    at async g (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:77:100986)
    at async f (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:77:102317)
    at async ne.fetchers.patchPackage (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:77:118194)
    at async w (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:37:45769)
    at async B (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:37:46239)
    at async Q (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:37:46715)
    at async C.fetchPackageFromCache (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:37:46954)
    at async ne.fetchers.fetch (/home/nixi/work/support/.yarn/releases/yarn-2.0.0-rc.36.cjs:77:117113)

This should now be fixed in master. Note that the integration is slightly less good in 3.6 than 3.9+, so if you depend on TS yourself, we still suggest to upgrade.

Still an issue.

yarn add [email protected]

4.1.0 is still in beta, and any support for it is best effort. It literally just got merged in the trunk, so you'll have to use the master branch to install it.

Thank you @arcanis !!!

Hey! Any updates on typescript 4.1 support? It's been out for 2 weeks now.

The fix has been released last Monday, in 2.4

Was this page helpful?
0 / 5 - 0 ratings