Skip to content

fix(code-tools): launch errors on Windows & Qwen Code auth issue#13400

Merged
GeorgeDong32 merged 8 commits intomainfrom
fix/cli-tools-windows-install
Mar 17, 2026
Merged

fix(code-tools): launch errors on Windows & Qwen Code auth issue#13400
GeorgeDong32 merged 8 commits intomainfrom
fix/cli-tools-windows-install

Conversation

@GeorgeDong32
Copy link
Collaborator

@GeorgeDong32 GeorgeDong32 commented Mar 11, 2026

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"
  • Windows Terminal launch failed
  • Qwen Code auth type incorrect, in docs

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())
  • Windows Terminal launch normally
  • Qwen Code auth type set to "openai" when package version >= 0.12.3

Fixes #12985 #13442 #13473

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

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
@GeorgeDong32 GeorgeDong32 force-pushed the fix/cli-tools-windows-install branch 2 times, most recently from 3bba0b9 to 6b5b104 Compare March 15, 2026 06:53
@GeorgeDong32 GeorgeDong32 force-pushed the fix/cli-tools-windows-install branch from 6b5b104 to 4dcfa3e Compare March 15, 2026 06:54
@GeorgeDong32 GeorgeDong32 changed the title fix(code-tools): redirect bun output to log file on Windows fix(code-tools): launch errors on Windows & Qwen Code auth issue Mar 15, 2026
@GeorgeDong32
Copy link
Collaborator Author

GeorgeDong32 commented Mar 15, 2026

Note

This comment was translated by Claude.

The last two issues are reproducible, and I have verified that they are resolved. However, I cannot reproduce #12985 on my side, so I tentatively believe it can be solved with output redirection. @DeJeune @beyondkmp feel free to try it when you have time.


Original Content

后两个issue可复现,我这边验证解决了。但是 #12985 我这边复现不出来,暂时判断是输出重定向可以解决的。 @DeJeune @beyondkmp 有空可以试试

Copy link
Contributor

@cherry-ai-bot cherry-ai-bot bot left a comment

Choose a reason for hiding this comment

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

I reviewed the current draft and found one blocking issue in the qwen-code fix path. The Windows Terminal quoting change and the bun-install logging workaround both look directionally good, but the qwen auth-type fix is currently incomplete.

…inal args

- Fix installedVersion not fetched when autoUpdateToLatest is false
  Separates version fetching from auto-update logic to ensure qwen-code
  auth-type detection works regardless of auto-update setting
  
- Remove unnecessary quotes from Windows Terminal profile name
  Fixes potential parsing issues with wt -p argument

Addresses review feedback on PR #13400
Replace custom compareVersions method with semver library for more robust
version comparison (handles v-prefix, prereleases, etc.). No new dependencies
needed as semver is already in package.json.

Addresses review feedback on PR #13400
Convert backslashes to forward slashes in log file path for better
cmd.exe compatibility. Addresses code review feedback on PR #13400
@GeorgeDong32 GeorgeDong32 marked this pull request as ready for review March 15, 2026 16:01
@GeorgeDong32 GeorgeDong32 requested a review from beyondkmp March 15, 2026 16:08
Copy link
Contributor

@cherry-ai-bot cherry-ai-bot bot left a comment

Choose a reason for hiding this comment

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

Re-reviewed the latest revision. The previous blocking issue in the qwen-code path is resolved: installedVersion is now fetched independently of the auto-update branch, so the --auth-type openai workaround applies to already-installed qwen-code users as intended. The follow-up semver change also makes the version gate more robust. I don't see a new blocking issue in the current revision. LGTM.

@GeorgeDong32 GeorgeDong32 requested a review from EurFelux March 17, 2026 03:32
@GeorgeDong32 GeorgeDong32 linked an issue Mar 17, 2026 that may be closed by this pull request
10 tasks
@GeorgeDong32 GeorgeDong32 mentioned this pull request Mar 17, 2026
10 tasks
Copy link
Collaborator

@DeJeune DeJeune left a comment

Choose a reason for hiding this comment

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

Overall the fix is well-structured. One null-safety issue found with semver.coerce() — see inline comment.

Refactor version comparison to explicitly check coerce result before passing
to semver.gte(). This improves code clarity and follows review feedback
from PR #13400.

Before: semver.gte(semver.coerce(installedVersion) || '0.0.0', '0.12.3')
After:  const coerced = semver.coerce(installedVersion)
       const needsAuthType = installedVersion && coerced && semver.gte(coerced, '0.12.3')
@GeorgeDong32 GeorgeDong32 merged commit b6f2284 into main Mar 17, 2026
7 checks passed
@GeorgeDong32 GeorgeDong32 deleted the fix/cli-tools-windows-install branch March 17, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants