Skip to content

Add JSON output method for doctor#22448

Open
SMillerDev wants to merge 4 commits into
mainfrom
feat/doctor/output_json
Open

Add JSON output method for doctor#22448
SMillerDev wants to merge 4 commits into
mainfrom
feat/doctor/output_json

Conversation

@SMillerDev

Copy link
Copy Markdown
Member

Add an option to output the brew doctor results in easily parseable JSON output.


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR.

Copilot AI review requested due to automatic review settings May 29, 2026 13:06

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea but I think this needs a lot of work before we can merge. We need to actually provide structured output from all diagnostics rather than relying on regexes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds JSON output support to brew doctor, making diagnostic results easier for scripts and tools to consume.

Changes:

  • Adds a --json switch to brew doctor.
  • Builds and prints a JSON object containing a support tier and findings.
  • Adds the generated Sorbet RBI predicate and a basic command spec.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
Library/Homebrew/cmd/doctor.rb Adds JSON output generation for doctor diagnostics.
Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/doctor.rbi Adds the json? argument predicate.
Library/Homebrew/test/cmd/doctor_spec.rb Adds a basic spec for brew doctor --json.
Files not reviewed (1)
  • Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/doctor.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/cmd/doctor.rb Outdated
Comment thread Library/Homebrew/cmd/doctor.rb Outdated
Comment thread Library/Homebrew/cmd/doctor.rb Outdated
Comment thread Library/Homebrew/test/cmd/doctor_spec.rb
@SMillerDev

SMillerDev commented May 29, 2026

Copy link
Copy Markdown
Member Author

Fair enough, I'd suggest a structure like this:

  • Title
  • Issue description
  • Tier indicator
  • Affects (list of full package names)
  • links: (list of URLs)
  • Remediation
    • commands (list)
    • text (or empty)

That we can then turn into a string or json object in the output.

@MikeMcQuaid

Copy link
Copy Markdown
Member

@SMillerDev yeh something like that sounds good. Also may want to have things like: affected formulae/casks, relevant URL(s).

@SMillerDev

Copy link
Copy Markdown
Member Author

Adjusted to include that

@MikeMcQuaid

Copy link
Copy Markdown
Member

@SMillerDev looks good except we need to return the structured data from diagnostics rather than using regex on their string output.

@SMillerDev

Copy link
Copy Markdown
Member Author

Yeah, fully planning to do that. Just wanted to work out a structure here before I get on reshaping all audit check output 😅

@SMillerDev SMillerDev force-pushed the feat/doctor/output_json branch from 81d5b7e to 3bbaf15 Compare June 2, 2026 09:27
@SMillerDev

Copy link
Copy Markdown
Member Author

JSON output:

{
  "tier": 1,
  "findings": [
    {
      "title": "Deprecated or disabled formulae",
      "issue": "Some installed formulae are deprecated or disabled.",
      "tier": 1,
      "affects": [
        "php@7.2",
        "mysql@8.0"
      ],
      "links": [],
      "remediation": {
        "commands": [],
        "text": "You should find replacements for the following formulae:\nmysql@8.0\n  php@7.2\n"
      }
    }
  ]
}

@SMillerDev SMillerDev force-pushed the feat/doctor/output_json branch from 3bbaf15 to bb17f35 Compare June 2, 2026 09:30

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is looking good! Will take another look when 🟢 and comments addressed. Happy to discuss more before addressing.

Comment thread Library/Homebrew/diagnostic.rb
Comment thread Library/Homebrew/diagnostic.rb Outdated
Comment thread Library/Homebrew/diagnostic.rb
@SMillerDev SMillerDev force-pushed the feat/doctor/output_json branch 4 times, most recently from e94087a to 2324ef7 Compare June 10, 2026 12:36
@SMillerDev SMillerDev force-pushed the feat/doctor/output_json branch 2 times, most recently from 1c6fc38 to df190b2 Compare June 22, 2026 14:37
@SMillerDev SMillerDev force-pushed the feat/doctor/output_json branch 4 times, most recently from b2f7195 to a816ce5 Compare June 23, 2026 08:30
@SMillerDev SMillerDev force-pushed the feat/doctor/output_json branch from a816ce5 to 800b5e2 Compare June 23, 2026 09:16
@SMillerDev SMillerDev requested a review from MikeMcQuaid June 23, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants