-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: surface a readable error when Git Bash is missing on Windows #2814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
liruifengv
merged 6 commits into
MoonshotAI:main
from
huangzheng2016:fix/windows-git-bash-not-found
Aug 11, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
362fa15
fix: surface a readable error when Git Bash is missing on Windows
huangzheng2016 ee43fb8
fix(agent-core-v2): translate probe rejection into HostProcessError f…
liruifengv 5e6e9ec
fix(agent-core-v2): narrow probe error to Error to satisfy only-throw…
liruifengv a493de2
fix(agent-core-v2): preserve probe error as cause when translating to…
liruifengv 0fdecd0
fix(agent-core-v2): keep checked paths out of the public probe error …
liruifengv c794ae0
fix(node-sdk): gate the host-environment wait in ensureConfigFile to …
liruifengv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@moonshot-ai/kimi-code": patch | ||
| --- | ||
|
|
||
| Show a clear error message on Windows when Git for Windows is not installed, instead of exiting silently. |
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
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
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
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
72 changes: 72 additions & 0 deletions
72
packages/agent-core-v2/test/os/backends/node-local/hostEnvironmentService.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /** | ||
| * HostEnvironmentService — shell-probe error handling. | ||
| * | ||
| * Stubs the host-environment probe to fail the way a Windows host without Git | ||
| * Bash does, so the suite runs identically on any platform. Pins the failure | ||
| * contract: `ready` rejects with the translated `HostProcessError` | ||
| * (`shell.git_bash_not_found`), sync field reads after a failed probe throw | ||
| * the same coded error, and the rejection never surfaces as an | ||
| * unhandledRejection while the App scope is being constructed (vitest fails | ||
| * the file on any unhandled rejection). | ||
| */ | ||
|
|
||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { ProbeShellNotFoundError } from '#/_base/execEnv/environmentProbe'; | ||
| import { HostEnvironmentService } from '#/os/backends/node-local/hostEnvironmentService'; | ||
| import { HostProcessError, OsProcessErrors } from '#/os/interface/hostProcess'; | ||
|
|
||
| vi.mock('#/_base/execEnv/environmentProbe', async (importOriginal) => { | ||
| const actual = await importOriginal<typeof import('#/_base/execEnv/environmentProbe')>(); | ||
| return { | ||
| ...actual, | ||
| probeHostEnvironmentFromNode: () => | ||
| Promise.reject( | ||
| new actual.ProbeShellNotFoundError('Git Bash missing (stubbed)', [ | ||
| 'C:\\Program Files\\Git\\bin\\bash.exe', | ||
| ]), | ||
| ), | ||
| }; | ||
| }); | ||
|
|
||
| vi.mock('#/_base/execEnv/loginShellPath', () => ({ | ||
| applyLoginShellPathFromNode: () => Promise.resolve(), | ||
| })); | ||
|
|
||
| describe('HostEnvironmentService', () => { | ||
| it('rejects ready with the translated HostProcessError when the probe fails', async () => { | ||
| const service = new HostEnvironmentService(); | ||
|
liruifengv marked this conversation as resolved.
|
||
|
|
||
| await expect(service.ready).rejects.toBeInstanceOf(HostProcessError); | ||
| await expect(service.ready).rejects.toMatchObject({ | ||
| code: OsProcessErrors.codes.SHELL_GIT_BASH_NOT_FOUND, | ||
| }); | ||
| }); | ||
|
|
||
| it('preserves the probe error as cause and checked paths as details', async () => { | ||
| const service = new HostEnvironmentService(); | ||
|
|
||
| const rejected: unknown = await service.ready.catch((error: unknown) => error); | ||
|
|
||
| expect(rejected).toBeInstanceOf(HostProcessError); | ||
| const hostError = rejected as HostProcessError; | ||
| expect(hostError.details).toEqual({ checkedPaths: ['C:\\Program Files\\Git\\bin\\bash.exe'] }); | ||
| expect(hostError.cause).toBeInstanceOf(ProbeShellNotFoundError); | ||
| }); | ||
|
|
||
| it('does not surface the ready rejection as an unhandledRejection', async () => { | ||
| const service = new HostEnvironmentService(); | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, 0)); | ||
|
|
||
| await expect(service.ready).rejects.toBeInstanceOf(HostProcessError); | ||
| }); | ||
|
|
||
| it('throws HostProcessError when reading fields after a failed probe', async () => { | ||
| const service = new HostEnvironmentService(); | ||
| await service.ready.catch(() => {}); | ||
|
|
||
| expect(() => service.shellPath).toThrow(HostProcessError); | ||
| expect(() => service.osKind).toThrow(HostProcessError); | ||
| }); | ||
| }); | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.