berry: [Bug] Cannot install typescript 4.3.2 with yarn 2 / node_modules linker
- I’d be willing to implement a fix
Describe the bug
While installing TS 4.3.2 with the node_modules linker yarn 2.4.1 fails with:
➤ YN0013: │ typescript@npm:4.3.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ typescript@patch:typescript@npm%3A4.3.2#builtin<compat/typescript>::version=4.3.2&hash=a45b0e can't be found in the cache and
➤ YN0013: │ typescript@npm:4.3.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0066: │ typescript@patch:typescript@npm%3A4.3.2#builtin<compat/typescript>::version=4.3.2&hash=a45b0e: Cannot apply hunk #2 (set enableInlineHunks for details)
To Reproduce
{
"version": "0.59.0",
"devDependencies": {
"typescript": "^4.3.0"
}
}
Environment if relevant (please complete the following information):
- OS: Windows 10
- Node version 16.2.0
- Yarn version 2.4.1
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 34
- Comments: 18 (8 by maintainers)
Commits related to this issue
- 🚑 Downgrade TypeScript Workaround for Yarn 2 TypeScript problem. See yarnpkg/berry#2935 and yarnpkg/berry#2938. — committed to gluons/vue-pack by gluons 3 years ago
- Upgrade TypeScript to 4.2.4 (this doesn't fix the build error) Core problem is that `yarn berry`, when using `pnp` mode, requires a patch to `typescript`. But we're using the `node-modules` linker. N... — committed to splitgraph/splitgraph.com by milesrichardson 3 years ago
- Upgrade TypeScript to 4.2.4 (this doesn't fix the build error) Core problem is that `yarn berry`, when using `pnp` mode, requires a patch to `typescript`. But we're using the `node-modules` linker. N... — committed to splitgraph/splitgraph.com by milesrichardson 3 years ago
- Bump yarn version to be able to install latest version of typescript https://github.com/yarnpkg/berry/issues/2935 — committed to labelflow/labelflow by RaynalHugo 3 years ago
- fix(.yarn): 🆙 upgrade yarn version fix Cannot install typescript 4.3.2 with yarn 2 / node_modules linker https://github.com/yarnpkg/berry/issues/2935 — committed to ali4heydari/ali4heydari.github.io by ali4heydari 3 years ago
- fix: yarn2 typescript 4.4.2 bug? roll back to v4.3.5 typescript@patch:typescript@npm%3A4.4.2#builtin<compat/typescript>::version=4.4.2&hash=ddfc1b: Cannot apply hunk #14 (set enableInlineHunks for d... — committed to hoonoh/aws-spot-price by hoonoh 3 years ago
The patch has been released in 2.4.2
Will the fix be backported to yarn 2?
@qrilka You need to be on v2 to use a specific version
Fixed in https://github.com/yarnpkg/berry/pull/2543
Same issue with @LouisSung. It shows ‘Completed’ but there are error “Cannot apply hunk”. I tried to run my project and the typescript not work.
Most likely if we look at the pattern https://github.com/yarnpkg/berry/blob/464618c2f7baba46a79d66849c1eda00cad1132e/packages/plugin-compat/extra/typescript/gen-typescript-patch.js#L18-L80
In Yarn 3 when the patch doesn’t apply correctly it will just ignore it so
node_modules
users shouldn’t have any issuesIt’s not that it’s “still happening” nor a “regression”, TypeScript released a new version so we need to update the PnP patch. The patch was updated in https://github.com/yarnpkg/berry/pull/3297 which was released in
3.1.0-rc.2
and we haven’t done a full release / backport yet, until we do that the fix is to run the following commands or locktypescript
to~4.3
I have the same error within this
package.json
and yarn2.4.2
. Is this a regression?To reproduce:
@merceyz Is there any plan on the date to release the patch? Seems impact a lot? (at least #2935, #2938, #2944, and #2952)
I can confirm it has been fixed with
yarn set version from sources
though, thank you for the quick fix : )[UPDATE1]
It’s weird that still failed when installing in Dockerfile… still checking) I gotUsage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)
when doingRUN yarn set version from sources
, whereasdocker run -it node:12.22.1-buster-slim sh
with manually typing in the command works…[UPDATE2]
The set version error is led by #2955 after some cross testing