fix: silence stderr on best-effort package-manager probes#491
Open
huangguang1999 wants to merge 1 commit into
Open
fix: silence stderr on best-effort package-manager probes#491huangguang1999 wants to merge 1 commit into
huangguang1999 wants to merge 1 commit into
Conversation
When bun is on PATH but its global directory was never initialized (no `bun add -g` ever run), launching the config TUI prints `error: No package.json was found for directory "~/.bun/install/global"` into the terminal. The TUI probes `bun pm bin -g` (and `where`/`which`, `npm prefix -g`, `npm root -g`) via execFileSync without an stdio option, so the child's stderr is inherited by the parent terminal even though the thrown error itself is caught and treated as "not found". Add stdio: ['ignore', 'pipe', 'ignore'] to these best-effort probes (stdout stays piped for the return value), matching the pattern already used elsewhere in the codebase. Adds regression tests asserting every probe call suppresses stderr and that a throwing bun probe degrades gracefully. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a machine where
bunis on PATH but its global directory was never initialized (the user never ranbun add -g— e.g. they installed ccstatusline vianpm install -g), launching the config TUI prints bun's error straight into the terminal:(Reported downstream in a localized fork: huangguang1999/ccstatusline-zh#39, with screenshots.)
Root cause
Installation inspection probes
bun pm bin -g(pluswhere/which,npm prefix -g,npm root -g) throughexecFileSyncwithout anstdiooption. Node's default inherits the child's stderr into the parent terminal, so even though the thrown error is caught (catch { return null; }), the stderr text has already leaked. On Windows,wheresimilarly writesINFO: Could not find files...to stderr when nothing matches.Other probes in the codebase already suppress stderr (e.g.
usage-fetch.tsusesstdio: ['pipe', 'pipe', 'ignore']) — these calls just missed the pattern.Fix
Add
stdio: ['ignore', 'pipe', 'ignore']to the best-effort probe calls (stdout stays piped for the return value). No behavior change: these functions already treat any failure as "not found".Tests
execFileSynccall carries stderr suppression (regression guard).bun run lintclean,bun test1630 tests green.🤖 Generated with Claude Code