Skip to content

Commit 3ad3052

Browse files
authored
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? <!-- Describe the rationale of your PR. --> <!-- Link all issues that it closes. (Closes/Resolves #xxxx.) --> ### 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 <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [ ] I will check that all automated PR checks pass before the PR gets reviewed.
1 parent 157da5c commit 3ad3052

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.yarn/versions/3e8e779b.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/core": patch
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-essentials"
10+
- "@yarnpkg/plugin-exec"
11+
- "@yarnpkg/plugin-file"
12+
- "@yarnpkg/plugin-git"
13+
- "@yarnpkg/plugin-github"
14+
- "@yarnpkg/plugin-http"
15+
- "@yarnpkg/plugin-init"
16+
- "@yarnpkg/plugin-interactive-tools"
17+
- "@yarnpkg/plugin-link"
18+
- "@yarnpkg/plugin-nm"
19+
- "@yarnpkg/plugin-npm"
20+
- "@yarnpkg/plugin-npm-cli"
21+
- "@yarnpkg/plugin-pack"
22+
- "@yarnpkg/plugin-patch"
23+
- "@yarnpkg/plugin-pnp"
24+
- "@yarnpkg/plugin-pnpm"
25+
- "@yarnpkg/plugin-stage"
26+
- "@yarnpkg/plugin-typescript"
27+
- "@yarnpkg/plugin-version"
28+
- "@yarnpkg/plugin-workspace-tools"
29+
- "@yarnpkg/builder"
30+
- "@yarnpkg/doctor"
31+
- "@yarnpkg/extensions"
32+
- "@yarnpkg/nm"
33+
- "@yarnpkg/pnpify"
34+
- "@yarnpkg/sdks"

packages/yarnpkg-core/sources/scriptUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export async function prepareExternalProject(cwd: PortablePath, outputPath: Port
254254
!packageManagerSelection?.packageManagerField;
255255

256256
await xfs.mktempPromise(async binFolder => {
257-
const env = await makeScriptEnv({binFolder, ignoreCorepack});
257+
const env = await makeScriptEnv({binFolder, ignoreCorepack, baseEnv: {...process.env, COREPACK_ENABLE_AUTO_PIN: `0`}});
258258

259259
const workflows = new Map([
260260
[PackageManager.Yarn1, async () => {

0 commit comments

Comments
 (0)