Skip to content

Hash validation failed for yarn when COREPACK_NPM_REGISTRY is set on one side #435

@zhyupe

Description

@zhyupe

Currently, yarn berry could be downloaded as two form, tar or js, depending on whether COREPACK_NPM_REGISTRY is set. However, the hash validation step simply calculates the shasum of download stream, and obviously the hashes mismatch.

For example, shasums for yarn 4.1.1 are:

61b9f63c5edc625867eeda36190a4efebdf7840052db5f6583e301a9d228eb43  cli-dist-4.1.1.tgz
f3cc0eda8e5560e529c7147565b30faa43b4e472d90e8634d7134a37c7f59781  yarn.js

Reproduce steps:

  1. Call corepack use [email protected] without COREPACK_NPM_REGISTRY being set. Hash will be written to package.json
"packageManager": "[email protected]+sha256.f3cc0eda8e5560e529c7147565b30faa43b4e472d90e8634d7134a37c7f59781"
  1. Copy the project to an environment where COREPACK_NPM_REGISTRY is set.
  2. Call corepack yarn, following error will be thrown:
Internal Error: Mismatch hashes. Expected f3cc0eda8e5560e529c7147565b30faa43b4e472d90e8634d7134a37c7f59781, got 61b9f63c5edc625867eeda36190a4efebdf7840052db5f6583e301a9d228eb43

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions