From a14ed616da7f400c011f442f3ba0a3c5ef8e357e Mon Sep 17 00:00:00 2001 From: LeSingh1 Date: Sun, 17 May 2026 18:36:53 -0700 Subject: [PATCH] [rush] Route lockfile-changed warning to stderr `rush list --json` writes `Lockfile was created or deleted. Assuming all projects are affected.` to stdout when the lockfile was added or removed in the diff range, which corrupts the JSON output and breaks pipes such as `rush list --json --impacted-by git: | jq .`. The information is useful diagnostic context, so rather than suppress it, route it through `terminal.writeWarningLine` (which writes to stderr) -- the standard CLI convention for warnings that should not pollute machine-readable stdout. Matches how the rest of this file already emits non-fatal diagnostics (see lines 418, 446, 458). Fixes #5406 --- .../fix-rush-list-json-stderr_2026-05-17-19-00.json | 11 +++++++++++ libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 common/changes/@microsoft/rush/fix-rush-list-json-stderr_2026-05-17-19-00.json diff --git a/common/changes/@microsoft/rush/fix-rush-list-json-stderr_2026-05-17-19-00.json b/common/changes/@microsoft/rush/fix-rush-list-json-stderr_2026-05-17-19-00.json new file mode 100644 index 00000000000..131d6335a6d --- /dev/null +++ b/common/changes/@microsoft/rush/fix-rush-list-json-stderr_2026-05-17-19-00.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "Route the \"Lockfile was created or deleted\" warning to stderr so that machine-readable output (e.g. `rush list --json`) remains parseable when the lockfile was added or removed in the diff range.", + "type": "patch", + "packageName": "@microsoft/rush" + } + ], + "packageName": "@microsoft/rush", + "email": "sshaurya914@gmail.com" +} diff --git a/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts b/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts index 43cd967a9d3..236f41285e9 100644 --- a/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts +++ b/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts @@ -220,11 +220,13 @@ export class ProjectChangeAnalyzer { if (shrinkwrapStatus) { if (shrinkwrapStatus.status !== 'M') { if (rushConfiguration.subspacesFeatureEnabled) { - terminal.writeLine( + terminal.writeWarningLine( `"${subspace.subspaceName}" subspace lockfile was created or deleted. Assuming all projects are affected.` ); } else { - terminal.writeLine(`Lockfile was created or deleted. Assuming all projects are affected.`); + terminal.writeWarningLine( + `Lockfile was created or deleted. Assuming all projects are affected.` + ); } for (const project of subspaceProjects) { changedProjects.add(project);