rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] `rush list --json` outputs non-JSON output when a lockfile is created or deleted

Open TAGraves opened this issue 3 months ago • 1 comments

Summary

If you create or delete your lockfile and run rush list --json, the following is output to stdout:

Lockfile was created or deleted. Assuming all projects are affected.
{
  "projects": [
     ...
  ]
}

This breaks automation that attempts to pipe the result of rush list --json to a tool like jq since the first line is not JSON.

Repro steps

  1. Delete a lockfile
  2. Commit
  3. Re-add the lockfile
  4. Run rush list --json --impacted-by git:$COMMIT_SHA_WHERE_LOCKFILE_DOES_NOT_EXIST

Expected result: Only JSON is output to stdout. Since the error is a useful one, perhaps it should be output to stderr to preserve the ability to pipe the JSON to jq?

Actual result: The message "Lockfile was created or deleted. Assuming all projects are affected." is printed to stdout before the JSON is printed.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.153.2
rushVersion from rush.json? 5.153.2
useWorkspaces from rush.json? No
Operating system? Linux
Would you consider contributing a PR? Yes
Node.js version (node -v)? 22.18.0

TAGraves avatar Oct 07 '25 18:10 TAGraves

Probably pretty simple to fix. Are you interested in putting together a PR?

iclanton avatar Oct 07 '25 22:10 iclanton