fix(auth): return the user-local external CLI as one native path on Windows

The user-local known dir is spelled %USERPROFILE%/.local/bin, so a Windows hit came back
with mixed separators in provider status and in the spawned ACP argv. Normalize the
resolved path.

Co-authored-by: Finn763 <165816600+finn763@users.noreply.github.com>
This commit is contained in:
Brooklyn NicholsonandFinn763 authored and brooklyn! committed 2026-10-07 14:19:47 -05:00
1 parent e894a7f82a
commit 865ba906c1
2 files changed
+22 -1

No files matched your search

+3 -1
View File
@@ -24,7 +24,9 @@ def resolve_external_process_command(command: str) -> Optional[str]:
lookup = os.path.abspath(os.path.expandvars(os.path.expanduser(command)))
found = locate_command(lookup, known_dirs=user_local_bin()).command
if found:
return found[0]
# Known dirs are written with "/" (%USERPROFILE%/.local/bin); normalize so a Windows hit
# reads as one native path in status and in the spawned argv.
return os.path.normpath(found[0])
from agent.anthropic_adapter import find_claude_code_cli
return find_claude_code_cli(command)
@@ -80,6 +80,25 @@ def test_external_process_status_finds_user_local_cli_outside_backend_path(
assert resolve_external_process_provider_credentials("copilot-acp")["command"] == str(cli)
@pytest.mark.platforms("windows")
def test_external_process_status_finds_user_profile_local_cli_as_native_path(
tmp_path, monkeypatch, _clean_copilot_env
):
"""The Windows user-local hit is one native path, not a mixed-separator join."""
local_bin = tmp_path / ".local" / "bin"
local_bin.mkdir(parents=True)
cli = local_bin / "copilot.exe"
cli.write_text("", encoding="utf-8")
monkeypatch.setenv("PATH", str(tmp_path / "backend-bin"))
status = get_external_process_provider_status("copilot-acp")
resolved = status["resolved_command"]
assert status["configured"] is True
assert "/" not in resolved and os.path.samefile(resolved, cli)
assert resolve_external_process_provider_credentials("copilot-acp")["command"] == resolved
def test_external_process_status_resolves_relative_configured_path_from_cwd(
tmp_path, monkeypatch, _clean_copilot_env
):