diff --git a/.changeset/strange-eagles-nail.md b/.changeset/strange-eagles-nail.md new file mode 100644 index 0000000000..3560beef9e --- /dev/null +++ b/.changeset/strange-eagles-nail.md @@ -0,0 +1,6 @@ +--- +"@pnpm/core": patch +"pnpm": patch +--- + +Don't break lockfile v6 on repeat install if `use-lockfile-v6` is not set to `true`. diff --git a/pkg-manager/core/src/install/extendInstallOptions.ts b/pkg-manager/core/src/install/extendInstallOptions.ts index c47fead349..8021b445f4 100644 --- a/pkg-manager/core/src/install/extendInstallOptions.ts +++ b/pkg-manager/core/src/install/extendInstallOptions.ts @@ -120,7 +120,7 @@ export interface StrictInstallOptions { allProjects: ProjectOptions[] resolveSymlinksInInjectedDirs: boolean dedupeDirectDeps: boolean - useLockfileV6: boolean + useLockfileV6?: boolean } export type InstallOptions = @@ -207,7 +207,6 @@ const defaults = async (opts: InstallOptions) => { resolveSymlinksInInjectedDirs: false, dedupeDirectDeps: false, resolvePeersFromWorkspaceRoot: false, - useLockfileV6: false, } as StrictInstallOptions } diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index 7cb4502e66..ea7b9b481a 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -279,6 +279,9 @@ export async function mutateModules ( path: path.join(opts.lockfileDir, patchFile.path), }), patchedDependencies) : undefined + if (opts.useLockfileV6 == null) { + opts.useLockfileV6 = ctx.wantedLockfile.lockfileVersion.toString().startsWith('6.') + } let needsFullResolution = !maybeOpts.ignorePackageManifest && lockfileIsUpToDate(ctx.wantedLockfile, { overrides: opts.overrides, @@ -879,7 +882,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => { : newLockfile if (opts.updateLockfileMinorVersion) { - if (opts.useLockfileV6 || newLockfile.lockfileVersion.toString().startsWith('6.')) { + if (opts.useLockfileV6) { newLockfile.lockfileVersion = LOCKFILE_VERSION_V6 } else { newLockfile.lockfileVersion = LOCKFILE_VERSION