From 3ad30526dac841e55c59570db59f684ce613ca49 Mon Sep 17 00:00:00 2001 From: Shima Ryuhei <65934663+islandryu@users.noreply.github.com> Date: Wed, 16 Oct 2024 07:52:25 +0900 Subject: [PATCH] fix(cli): Set COREPACK_ENABLE_AUTO_PIN=0 during local pack of github packages (#6529) Different Corepack versions caused discrepancies in the addition of `packageManager` during Yarn installation, resulting in checksum changes and installation failures. This commit standardizes the behavior to avoid such errors. ## What's the problem this PR addresses? ### issue Error occurs because checksum changes with different corepack versions. ### repro ``` json "dependencies": { "react-native-scrollable-tab-view": "https://github.com/ptomasroos/react-native-scrollable-tab-view#74c3ce7332c706732ef0e590c31e6558e8c0f2d5" } ``` When I generate yarn.lock with corepack0.18.0 and install with 0.29.4, I get the following error. ``` react-native-scrollable-tab-view@https://github.com/ptomasroos/react-native-scrollable-tab-view.git#commit=74c3ce7332c706732ef0e590c31e6558e8c0f2d5: The remote archive doesn't match the expected checksum ``` This is at least the environment in which it occurred to me. I also think it probably occurs in any github url ### why The github pakcage is packed locally by running the `yarn pack` command It seems that corepack changes the checksum of the package by setting the packageManager field to package.json when this command is executed. ## How did you fix it? Set COREPACK_ENABLE_AUTO_PIN to not add packageManager field ## Checklist - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). - [x] I have set the packages that need to be released for my changes to be effective. - [ ] I will check that all automated PR checks pass before the PR gets reviewed. --- .yarn/versions/3e8e779b.yml | 34 ++++++++++++++++++++ packages/yarnpkg-core/sources/scriptUtils.ts | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .yarn/versions/3e8e779b.yml diff --git a/.yarn/versions/3e8e779b.yml b/.yarn/versions/3e8e779b.yml new file mode 100644 index 000000000000..2d6a48f178d8 --- /dev/null +++ b/.yarn/versions/3e8e779b.yml @@ -0,0 +1,34 @@ +releases: + "@yarnpkg/cli": patch + "@yarnpkg/core": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-exec" + - "@yarnpkg/plugin-file" + - "@yarnpkg/plugin-git" + - "@yarnpkg/plugin-github" + - "@yarnpkg/plugin-http" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-link" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - "@yarnpkg/builder" + - "@yarnpkg/doctor" + - "@yarnpkg/extensions" + - "@yarnpkg/nm" + - "@yarnpkg/pnpify" + - "@yarnpkg/sdks" diff --git a/packages/yarnpkg-core/sources/scriptUtils.ts b/packages/yarnpkg-core/sources/scriptUtils.ts index 2d9b04c74f47..2dcd7e59e6db 100644 --- a/packages/yarnpkg-core/sources/scriptUtils.ts +++ b/packages/yarnpkg-core/sources/scriptUtils.ts @@ -254,7 +254,7 @@ export async function prepareExternalProject(cwd: PortablePath, outputPath: Port !packageManagerSelection?.packageManagerField; await xfs.mktempPromise(async binFolder => { - const env = await makeScriptEnv({binFolder, ignoreCorepack}); + const env = await makeScriptEnv({binFolder, ignoreCorepack, baseEnv: {...process.env, COREPACK_ENABLE_AUTO_PIN: `0`}}); const workflows = new Map([ [PackageManager.Yarn1, async () => {