Skip to content

[Bug]: check-prerequisites.ps1 writes errors to stdout, corrupting --json output #3122

Description

@Quratulain-bilal

Bug Description

the powershell check-prerequisites.ps1 writes its validation errors and run-hints with Write-Output, which goes to stdout. this script is normally run with -Json and the agent parses its stdout as json. when validation fails (e.g. plan.md is missing), the error text lands on stdout instead of json, so the consumer gets something like ERROR: plan.md not found ... where it expects a json object, and parsing breaks.

the bash counterpart doesn't have this - it sends the same errors to stderr (>&2), keeping stdout clean. the sibling powershell scripts are also fine: setup-tasks.ps1 and common.ps1's Get-FeaturePathsEnv both use [Console]::Error.WriteLine. only check-prerequisites.ps1 is the odd one out.

Steps to Reproduce

  1. in a spec-kit project with a feature dir but no plan.md, run:
    pwsh .specify/scripts/powershell/check-prerequisites.ps1 -Json
  2. capture stdout only (e.g. redirect stderr away).
  3. observe stdout contains the error string instead of json.

compare with bash:
bash .specify/scripts/bash/check-prerequisites.sh --json - stdout stays empty, the error goes to stderr.

Expected Behavior

errors and run-hints go to stderr; stdout only ever carries the json (or the documented text payload). both shells behave the same.

Actual Behavior

the six error/hint lines (check-prerequisites.ps1 lines 86, 88, 93, 95, 101, 103 on main) use Write-Output, so they go to stdout and pollute the -Json output.

Additional Context

suggested fix: switch those six lines to [Console]::Error.WriteLine, matching the bash script and the other powershell scripts. small diff.

note: i used an ai assistant to help investigate and write this up.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions