diff --git a/.changeset/fair-hotels-suffer.md b/.changeset/fair-hotels-suffer.md new file mode 100644 index 0000000000..12c4d51161 --- /dev/null +++ b/.changeset/fair-hotels-suffer.md @@ -0,0 +1,6 @@ +--- +"@pnpm/core": patch +"@pnpm/headless": patch +--- + +Add more details to the frozen lockfile error. diff --git a/.changeset/many-colts-think.md b/.changeset/many-colts-think.md new file mode 100644 index 0000000000..bda17c42ec --- /dev/null +++ b/.changeset/many-colts-think.md @@ -0,0 +1,5 @@ +--- +"@pnpm/plugin-commands-installation": patch +--- + +Document `--no-frozen-lockfile` explicitly in the help of the install command. diff --git a/packages/core/src/install/index.ts b/packages/core/src/install/index.ts index df94567186..d1afaad10c 100644 --- a/packages/core/src/install/index.ts +++ b/packages/core/src/install/index.ts @@ -251,7 +251,9 @@ export async function mutateModules ( ) ) { if (needsFullResolution) { - throw new PnpmError('FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE', 'Cannot perform a frozen installation because the lockfile needs updates') + 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"', + }) } if (!ctx.existsWantedLockfile) { if (ctx.projects.some((project) => pkgHasDependencies(project.manifest))) { diff --git a/packages/headless/src/index.ts b/packages/headless/src/index.ts index bb2bc68699..de8fd11e82 100644 --- a/packages/headless/src/index.ts +++ b/packages/headless/src/index.ts @@ -155,7 +155,9 @@ export default async (opts: HeadlessOptions) => { if (!satisfiesPackageManifest(wantedLockfile, manifest, id)) { throw new PnpmError('OUTDATED_LOCKFILE', `Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up-to-date with ` + - path.relative(lockfileDir, path.join(rootDir, 'package.json'))) + path.relative(lockfileDir, path.join(rootDir, 'package.json')), { + 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"', + }) } } } diff --git a/packages/plugin-commands-installation/src/install.ts b/packages/plugin-commands-installation/src/install.ts index 2b0c946440..18b28e52b3 100644 --- a/packages/plugin-commands-installation/src/install.ts +++ b/packages/plugin-commands-installation/src/install.ts @@ -123,8 +123,8 @@ For options that may be used with `-r`, see "pnpm help recursive"', name: '--lockfile-only', }, { - description: "Don't generate a lockfile and fail if an update is needed", - name: '--frozen-lockfile', + description: "Don't generate a lockfile and fail if an update is needed. This setting is on by default in CI environments, so use --no-frozen-lockfile if you need to disable it for some reason", + name: '--[no-]frozen-lockfile', }, { description: `If the available \`${WANTED_LOCKFILE}\` satisfies the \`package.json\` then perform a headless installation`,