pnpm: `pnpm install --frozen-lockfile` fails with pnpm v9

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

9.0.0

Which area(s) of pnpm are affected? (leave empty if unsure)

Lockfile

Link to the code that reproduces this issue or a replay of the bug

https://github.com/DimensionDev/Maskbook/pull/11571/files

Reproduction steps

Clone the PR and try an upgrade

Describe the Bug

I upgraded pnpm from 8.7.6 to 9.0.0 and the lockfile is broken (as you can see in the link I mentioned).

One thing you can observe is that: peer dependencies to react are mostly resolved to 18.2.0, not 0.0.0-experimental-8039e6d0b-20231026 as I specified in package.json/pnpm/peerDependencyRules/allowedVersions.

I tried to remove the whole section of allowedVersions and reinstall, then add it back hope it can re-resolve dependencies, but that does not work.

Expected Behavior

Upgrade and keep my peer dependencies version correct

Which Node.js version are you using?

21

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 months ago
  • Reactions: 4
  • Comments: 30 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Can confirm and also looking to hear from the team if the lockfile not being backwards compatible was intended:

ERR_PNPM_FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE  Cannot perform a frozen installation because the version of the lockfile is incompatible with this version of pnpm

A question: why is lockfile version 9.0 and not 7.0?

By default pnpm install fails in CI if it detects that updates should be made to the lockfile. That will be fixed in 9.0.1.

Not sure what the issue with corepack is

A question: why is lockfile version 9.0 and not 7.0?

The lockfile version will be the same as the pnpm version where it was introduced.

Also if anyone stumble here in the same case as me - it seems like turborepo pruning fails with the new lockfile format and causes the same error as described here. I’ve opened issue on their side - https://github.com/vercel/turbo/issues/7993

I tested it in a node.js docker container (docker run --rm -it node sh). All seems to work correctly. Maybe you have a packageManager field in your package.json, try to use:

corepack use pnpm@8.15.5

Which should update the field in package.json.

Yep, I also mentioned that section of pnpm docks with packageManager field in package.json, bc it solved the issue for us.

Nevertheless, I beg my pardon. Doublechecked the pipe logs. The below is not enough:

corepack enable
corepack prepare pnpm@8.15.5 --activate

It proceeds with enabling “pnpm@latest” instead of “pnpm@8.15.5” that’s is expected according to a node v.18 docs.

It’s solely corepack documentation issue, and has nothing to do with pnpm.

Lockfile v6 will work with pnpm v9 but only as readonly (after this fix: https://github.com/pnpm/pnpm/pull/7935). v9 will not make updates in the previous format.

As I said before. This is a breaking change for a reason. We had to change the lockfile format in order to fix some issues with peer dependencies. The fix was too big to port it to v8.

pnpm 9 seems to be incompatible with lockfile v6.0:

  • Running pnpm install --frozen-lockfile on a v6 lockfile results in the error  ERR_PNPM_FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE  Cannot perform a frozen installation because the version of the lockfile is incompatible with this version of pnpm
  • Running pnpm install with no arguments updates the lockfile to v9, which is incompatible with pnpm 8

Is no lockfile version compatible with both pnpm 8 and 9?

The changelog seemed to suggest that Lockfile v6 is supported in pnpm 9, but I can’t get it to work.

Edit: Readonly support for Lockfile v6 as introduced in pnpm 9.0.1 is a good compromise

A temporary solution for me was to get my workflows to install a specific pnpm version rather than the latest version

Can confirm and also looking to hear from the team if the lockfile not being backwards compatible was intended:

ERR_PNPM_FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE  Cannot perform a frozen installation because the version of the lockfile is incompatible with this version of pnpm

I am seeing the exact same issue with pnpm v9 and a lock file with version 6. I thought only v5 was dropped?