diff --git a/.changeset/tender-ties-punch.md b/.changeset/tender-ties-punch.md new file mode 100644 index 0000000000..3377731203 --- /dev/null +++ b/.changeset/tender-ties-punch.md @@ -0,0 +1,6 @@ +--- +"@pnpm/core": patch +"pnpm": patch +--- + +Improve the outdated lockfile error message [#6304](https://github.com/pnpm/pnpm/pull/6304). diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index ed4162cb82..f3544a3fff 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -351,9 +351,16 @@ export async function mutateModules ( ) ) { if (needsFullResolution) { - throw new PnpmError('FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE', 'Cannot perform a frozen installation because the lockfile needs updates', { - hint: 'Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"', - }) + throw new PnpmError('FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE', + 'Cannot perform a frozen installation because the version of the lockfile is incompatible with this version of pnpm', + { + hint: `Try either: +1. Aligning the version of pnpm that generated the lockfile with the version that installs from it, or +2. Migrating the lockfile so that it is compatible with the newer version of pnpm, or +3. Using "pnpm install --no-frozen-lockfile". +Note that in CI environments, this setting is enabled by default.`, + } + ) } if (opts.lockfileOnly) { // The lockfile will only be changed if the workspace will have new projects with no dependencies. diff --git a/pkg-manager/core/test/install/overrides.ts b/pkg-manager/core/test/install/overrides.ts index 1bab2f9552..8b6f20a566 100644 --- a/pkg-manager/core/test/install/overrides.ts +++ b/pkg-manager/core/test/install/overrides.ts @@ -95,7 +95,7 @@ test('versions are replaced with versions specified through overrides option', a }, await testDefaults({ frozenLockfile: true, overrides })) ).rejects.toThrow( new PnpmError('FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE', - 'Cannot perform a frozen installation because the lockfile needs updates' + 'Cannot perform a frozen installation because the version of the lockfile is incompatible with this version of pnpm' ) ) }) diff --git a/pkg-manager/core/test/install/packageExtensions.ts b/pkg-manager/core/test/install/packageExtensions.ts index 4bf601baeb..b336e8600a 100644 --- a/pkg-manager/core/test/install/packageExtensions.ts +++ b/pkg-manager/core/test/install/packageExtensions.ts @@ -89,7 +89,7 @@ test('manifests are extended with fields specified by packageExtensions', async }, await testDefaults({ frozenLockfile: true, packageExtensions })) ).rejects.toThrow( new PnpmError('FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE', - 'Cannot perform a frozen installation because the lockfile needs updates' + 'Cannot perform a frozen installation because the version of the lockfile is incompatible with this version of pnpm' ) ) })