diff --git a/.changeset/hot-lies-rescue.md b/.changeset/hot-lies-rescue.md new file mode 100644 index 0000000000..60faff7bc3 --- /dev/null +++ b/.changeset/hot-lies-rescue.md @@ -0,0 +1,5 @@ +--- +"@pnpm/core": patch +--- + +When the lockfile is not up to date make it clear what `package.json` is out of sync. diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index a290415ef4..5583559ff3 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -441,7 +441,7 @@ Note that in CI environments, this setting is enabled by default.`, throw new PnpmError('OUTDATED_LOCKFILE', `Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up to date with ` + - path.relative(opts.lockfileDir, path.join(rootDir, 'package.json')), { + path.join('', path.relative(opts.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" Failure reason: diff --git a/pkg-manager/core/test/install/frozenLockfile.ts b/pkg-manager/core/test/install/frozenLockfile.ts index 7822d95c03..7691de8ec0 100644 --- a/pkg-manager/core/test/install/frozenLockfile.ts +++ b/pkg-manager/core/test/install/frozenLockfile.ts @@ -28,7 +28,7 @@ test(`frozen-lockfile: installation fails if specs in package.json don't match t 'is-positive': '^3.1.0', }, }, testDefaults({ frozenLockfile: true })) - ).rejects.toThrow(`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up to date with package.json`) + ).rejects.toThrow(`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up to date with ${path.join('', 'package.json')}`) }) test(`frozen-lockfile+hoistPattern: installation fails if specs in package.json don't match the ones in ${WANTED_LOCKFILE}`, async () => { @@ -46,7 +46,7 @@ test(`frozen-lockfile+hoistPattern: installation fails if specs in package.json 'is-positive': '^3.1.0', }, }, testDefaults({ frozenLockfile: true, hoistPattern: '*' })) - ).rejects.toThrow(`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up to date with package.json`) + ).rejects.toThrow(`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up to date with ${path.join('', 'package.json')}`) }) test(`frozen-lockfile: fail on a shared ${WANTED_LOCKFILE} that does not satisfy one of the package.json files`, async () => { @@ -97,7 +97,7 @@ test(`frozen-lockfile: fail on a shared ${WANTED_LOCKFILE} that does not satisfy await expect( mutateModules(projects, testDefaults({ frozenLockfile: true, allProjects: [project1, project2] })) - ).rejects.toThrow(`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up to date with p1${path.sep}package.json`) + ).rejects.toThrow(`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up to date with ${path.join('', 'p1/package.json')}`) }) test(`frozen-lockfile: should successfully install when ${WANTED_LOCKFILE} is available`, async () => {