Skip to content

Commit 1dea9a3

Browse files
Activer007freestylefly
authored andcommitted
fix(agent): preserve path precedence in cli probes
1 parent 9cdac15 commit 1dea9a3

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/libs/externalAgentEnvironment.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ test('probes CLI commands asynchronously and isolates version timeouts', async (
3636

3737
expect(claude).toMatchObject({
3838
found: true,
39+
path: path.join(tempDir, 'claude'),
3940
version: 'claude-test 1.0.0',
4041
});
4142
expect(claude?.checking).toBeUndefined();

src/main/libs/externalAgentEnvironment.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,12 @@ const runCommand = (
423423
const buildProbeEnv = (): NodeJS.ProcessEnv => ({
424424
...process.env,
425425
PATH: [
426+
process.env.PATH ?? '',
426427
path.join(homeDir(), '.npm-global', 'bin'),
427428
path.join(homeDir(), '.local', 'bin'),
428429
'/opt/homebrew/bin',
429430
'/usr/local/bin',
430-
resolveUserShellPath() ?? process.env.PATH ?? '',
431+
resolveUserShellPath() ?? '',
431432
].join(path.delimiter),
432433
});
433434

@@ -513,7 +514,9 @@ const resolveCommand = async (command: string): Promise<CommandResolution> => {
513514
}
514515
}
515516

516-
const result = await runCommand(process.platform === 'win32' ? 'where' : 'which', [command]);
517+
const result = await runCommand(process.platform === 'win32' ? 'where' : 'which', [command], {
518+
env: buildProbeEnv(),
519+
});
517520
if (result.status === 0) {
518521
const candidates = result.stdout.split(/\r?\n/).map(line => line.trim()).filter(Boolean);
519522
const commandPath = process.platform === 'win32'

0 commit comments

Comments
 (0)