Skip to content

fix(code-tools): redirect bun output to log file on Windows#13400

Draft
GeorgeDong32 wants to merge 2 commits intomainfrom
fix/cli-tools-windows-install
Draft

fix(code-tools): redirect bun output to log file on Windows#13400
GeorgeDong32 wants to merge 2 commits intomainfrom
fix/cli-tools-windows-install

Conversation

@GeorgeDong32
Copy link
Collaborator

What this PR does

Before this PR:

  • CLI tools (qwen-code, Claude Code, GitHub Copilot CLI, etc.) fail to start on Windows
  • bun install's multiline output (e.g., "Resolving [1/4]\nBun v1.2.9...") is misinterpreted by cmd.exe as separate commands
  • Users see errors like "'Resolving' is not recognized as an internal or external command"

After this PR:

  • Redirect bun install output to a log file on Windows
  • Log file location: userData/logs/cli-tools-install.log (via loggerService.getLogsDir())
  • macOS/Linux behavior unchanged (terminals handle multiline output correctly)
  • Removes unused app import from electron

Fixes #12985

Why we need it and why it was done in this way

The following tradeoffs were made:

  • Using file redirection (>> "logfile" 2>&1) instead of --silent flag to preserve debug information for troubleshooting
  • Windows-only fix since macOS/Linux terminals correctly handle multiline output

The following alternatives were considered:

  • Using bun install --silent: Rejected because it would lose all debug information
  • Using >/dev/null 2>&1: Rejected because it would completely discard output with no way to debug installation failures

Links to places where the discussion took place: #12985

Breaking changes

None

Special notes for your reviewer

  • The fix uses loggerService.getLogsDir() to ensure logs are written to the same directory as other Cherry Studio logs
  • Tested on Windows with qwen-code, GitHub Copilot CLI, and other affected tools

Checklist

Release note

Fix CLI tools failing to start on Windows by redirecting bun install output to log file

On Windows, `cmd.exe` can misinterpret multiline output from global CLI tool installations (e.g., Bun), leading to command execution failures.

This change redirects the standard output and error of CLI tool installation commands to a log file on Windows, preventing `cmd.exe` from misinterpreting the output. This ensures more reliable and stable installations of CLI tools.

Log files are created in the application's user data directory.
Replace app.getPath('userData') with loggerService.getLogsDir() to ensure
CLI tool install logs are written to the same directory as other Cherry
Studio logs. Removes unused 'app' import from electron.

Fixes #12985
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.

[Bug]: Some CLI commands in the code cli module fail to start

1 participant