Skip to content

Commit bc3496b

Browse files
committed
fix(validation): disable implicit pnpm installs
1 parent 12cfc66 commit bc3496b

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/repair/validation-command-utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,13 @@ export function validationCommandForExecution(parts: readonly string[]): string[
712712
return [...envPrefix, "npm", "--ignore-scripts", ...commandParts.slice(1)];
713713
}
714714
if (invocation.executable === "pnpm") {
715+
// pnpm can otherwise run an implicit install when its disposable validation
716+
// profile uses a different store. Dependency setup is a separate reviewed
717+
// phase, so validation must execute the requested script without mutation.
715718
return [
716719
...envPrefix,
717720
"pnpm",
721+
"--config.verify-deps-before-run=false",
718722
"--config.enable-pre-post-scripts=false",
719723
...commandParts.slice(1),
720724
];

test/repair/target-validation.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ test("bun test is treated as the built-in runner instead of a package script", (
802802
);
803803
});
804804

805-
test("package validation execution suppresses lifecycle hooks", () => {
805+
test("package validation execution suppresses lifecycle hooks and implicit installs", () => {
806806
assert.deepEqual(validationCommandForExecution(["npm", "run", "check"]), [
807807
"npm",
808808
"--ignore-scripts",
@@ -811,6 +811,7 @@ test("package validation execution suppresses lifecycle hooks", () => {
811811
]);
812812
assert.deepEqual(validationCommandForExecution(["pnpm", "--filter", "app", "check"]), [
813813
"pnpm",
814+
"--config.verify-deps-before-run=false",
814815
"--config.enable-pre-post-scripts=false",
815816
"--fail-if-no-match",
816817
"--filter",
@@ -819,6 +820,7 @@ test("package validation execution suppresses lifecycle hooks", () => {
819820
]);
820821
assert.deepEqual(validationCommandForExecution(["pnpm", "run", "--filter", "app", "check"]), [
821822
"pnpm",
823+
"--config.verify-deps-before-run=false",
822824
"--config.enable-pre-post-scripts=false",
823825
"--fail-if-no-match",
824826
"run",
@@ -1101,7 +1103,7 @@ if (args.includes("--fail-if-no-match")) {
11011103
);
11021104
assert.equal(
11031105
fs.readFileSync(logPath, "utf8"),
1104-
"--config.enable-pre-post-scripts=false --fail-if-no-match --filter __clawsweeper_no_such_workspace__ check",
1106+
"--config.verify-deps-before-run=false --config.enable-pre-post-scripts=false --fail-if-no-match --filter __clawsweeper_no_such_workspace__ check",
11051107
);
11061108
});
11071109

@@ -3280,8 +3282,8 @@ if (args[0] === "enable") {
32803282
assert.deepEqual(
32813283
targetInvocations.filter((line) => line.endsWith("verify")),
32823284
[
3283-
"--config.enable-pre-post-scripts=false verify",
3284-
"--config.enable-pre-post-scripts=false verify",
3285+
"--config.verify-deps-before-run=false --config.enable-pre-post-scripts=false verify",
3286+
"--config.verify-deps-before-run=false --config.enable-pre-post-scripts=false verify",
32853287
],
32863288
);
32873289
});
@@ -3353,8 +3355,8 @@ if (args[0] === "enable") {
33533355
assert.equal(fs.existsSync(maliciousMarker), false);
33543356
assert.deepEqual(fs.readFileSync(logPath, "utf8").trim().split(/\r?\n/), [
33553357
"install --frozen-lockfile --prefer-offline --ignore-scripts --ignore-pnpmfile --config.registry=https://registry.npmjs.org/ --config.engine-strict=false --config.enable-pre-post-scripts=false",
3356-
"--config.enable-pre-post-scripts=false first",
3357-
"--config.enable-pre-post-scripts=false second",
3358+
"--config.verify-deps-before-run=false --config.enable-pre-post-scripts=false first",
3359+
"--config.verify-deps-before-run=false --config.enable-pre-post-scripts=false second",
33583360
]);
33593361
},
33603362
);
@@ -3957,7 +3959,7 @@ if (args[0] === "enable") {
39573959
assert.equal(fs.existsSync(maliciousMarker), false);
39583960
assert.deepEqual(fs.readFileSync(logPath, "utf8").trim().split(/\r?\n/), [
39593961
"0.34.0-fixture install --frozen-lockfile --prefer-offline --ignore-scripts --ignore-pnpmfile --config.registry=https://registry.npmjs.org/ --config.engine-strict=false --config.enable-pre-post-scripts=false",
3960-
"0.34.0-fixture --config.enable-pre-post-scripts=false verify",
3962+
"0.34.0-fixture --config.verify-deps-before-run=false --config.enable-pre-post-scripts=false verify",
39613963
]);
39623964
},
39633965
);

0 commit comments

Comments
 (0)