Skip to content

Commit

Permalink
fix(cli): Set COREPACK_ENABLE_AUTO_PIN=0 during local pack of github …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
islandryu authored Oct 15, 2024
1 parent 157da5c commit 3ad3052
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .yarn/versions/3e8e779b.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/scriptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 3ad3052

Please sign in to comment.