Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package name mismatch with optional deps #4566

Closed
jondlm opened this issue Apr 13, 2022 · 1 comment · Fixed by #4580
Closed

Package name mismatch with optional deps #4566

jondlm opened this issue Apr 13, 2022 · 1 comment · Fixed by #4580
Milestone

Comments

@jondlm
Copy link
Contributor

jondlm commented Apr 13, 2022

  • pnpm version: bug first showed up in 6.32.2, also present in v7.0.0-rc.3
  • node -v prints: 16.14.0
  • Windows, macOS, or Linux?: macOS

This bug is very similar to #4565 but has a slightly different root cause.

Code to reproduce the issue:

This bug appears to originate with #4395. My debugging indicates that wantedDependency.optional on this line is set to true and therefore causing a problematic resolve (the dep should be pinned to the lockfile version and not resolved).

-> minimal reproduction

Repro with pnpm --filter b add is-negative

Pseudo workspace layout

a/
  package.json -> { name: a, dependencies: { graceful-fs: ^4.2.6 } }
b/
  package.json -> { name: b, optionalDependencies: { graceful-fs: ^4.2.5 } }

pnpm-lock.yaml

lockfileVersion: 5.3

importers:

  .:
    specifiers: {}

  a:
    specifiers:
      graceful-fs: ^4.2.6
    dependencies:
      graceful-fs: 4.2.6

  b:
    specifiers:
      graceful-fs: ^4.2.5
    optionalDependencies:
      graceful-fs: 4.2.5

packages:

  /graceful-fs/4.2.5:
    resolution: {integrity: sha512-kBBSQbz2K0Nyn+31j/w36fUfxkBW9/gfwRWdUY1ULReH3iokVJgddZAFcD1D0xlgTmFxJCbUkUclAlc6/IDJkw==}
    dev: false

  /graceful-fs/4.2.6:
    resolution: {integrity: sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==}
    requiresBuild: true
    dev: false
    optional: true

pnpm-workspace.yaml

packages:
  - 'a'
  - 'b'

Expected behavior:

Packages is added cleanly without error.

Actual behavior:

Pnpm fails with this error:

.                                        |  WARN  Package name mismatch found while reading {"integrity":"sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==","registry":"https://registry.npmjs.org/","tarball":"https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz"} from the store. This means that the lockfile is broken. Expected package: graceful-fs@4.2.5. Actual package in the store by the given integrity: graceful-fs@4.2.6.
 ERR_PNPM_ERR_PNPM_UNEXPECTED_PKG_CONTENT_IN_STORE  The lockfile is broken! A full installation will be performed in an attempt to fix it.
.                                        |   +1 +
 ERR_PNPM_UNEXPECTED_PKG_CONTENT_IN_STORE  Package name mismatch found while reading {"integrity":"sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==","registry":"https://registry.npmjs.org/","tarball":"https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz"} from the store. This means that the lockfile is broken. Expected package: graceful-fs@4.2.6. Actual package in the store by the given integrity: graceful-fs@4.2.10.

seo (my personal name for the bug): bus-watt

@jondlm
Copy link
Contributor Author

jondlm commented Apr 20, 2022

Just wanted to say thank you for fixing this! And thanks for all your hard work on this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants