Skip to content

Commit 58cfffc

Browse files
ashwin-antclaude
andauthored
fix: use PowerShell installer for Windows CLI download (#343)
The bash install script (install.sh) explicitly rejects Windows. Use the PowerShell installer (install.ps1) instead when running on Windows, matching the approach used in test.yml. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent 35dd5b4 commit 58cfffc

File tree

1 file changed

+46
-12
lines changed

1 file changed

+46
-12
lines changed

scripts/download_cli.py

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,21 @@ def get_cli_version() -> str:
2020

2121
def find_installed_cli() -> Path | None:
2222
"""Find the installed Claude CLI binary."""
23-
# Check common installation locations
24-
locations = [
25-
Path.home() / ".local/bin/claude",
26-
Path("/usr/local/bin/claude"),
27-
Path.home() / "node_modules/.bin/claude",
28-
]
23+
system = platform.system()
24+
25+
if system == "Windows":
26+
# Windows installation locations (matches test.yml: $USERPROFILE\.local\bin)
27+
locations = [
28+
Path.home() / ".local" / "bin" / "claude.exe",
29+
Path(os.environ.get("LOCALAPPDATA", "")) / "Claude" / "claude.exe",
30+
]
31+
else:
32+
# Unix installation locations
33+
locations = [
34+
Path.home() / ".local" / "bin" / "claude",
35+
Path("/usr/local/bin/claude"),
36+
Path.home() / "node_modules" / ".bin" / "claude",
37+
]
2938

3039
# Also check PATH
3140
cli_path = shutil.which("claude")
@@ -42,18 +51,43 @@ def find_installed_cli() -> Path | None:
4251
def download_cli() -> None:
4352
"""Download Claude Code CLI using the official install script."""
4453
version = get_cli_version()
54+
system = platform.system()
4555

4656
print(f"Downloading Claude Code CLI version: {version}")
4757

48-
# Download and run install script
49-
install_script = "curl -fsSL https://claude.ai/install.sh | bash"
50-
if version != "latest":
51-
install_script = f"curl -fsSL https://claude.ai/install.sh | bash -s {version}"
58+
# Build install command based on platform
59+
if system == "Windows":
60+
# Use PowerShell installer on Windows
61+
if version == "latest":
62+
install_cmd = [
63+
"powershell",
64+
"-ExecutionPolicy",
65+
"Bypass",
66+
"-Command",
67+
"irm https://claude.ai/install.ps1 | iex",
68+
]
69+
else:
70+
install_cmd = [
71+
"powershell",
72+
"-ExecutionPolicy",
73+
"Bypass",
74+
"-Command",
75+
f"& ([scriptblock]::Create((irm https://claude.ai/install.ps1))) {version}",
76+
]
77+
else:
78+
# Use bash installer on Unix-like systems
79+
if version == "latest":
80+
install_cmd = ["bash", "-c", "curl -fsSL https://claude.ai/install.sh | bash"]
81+
else:
82+
install_cmd = [
83+
"bash",
84+
"-c",
85+
f"curl -fsSL https://claude.ai/install.sh | bash -s {version}",
86+
]
5287

5388
try:
5489
subprocess.run(
55-
install_script,
56-
shell=True,
90+
install_cmd,
5791
check=True,
5892
capture_output=True,
5993
)

0 commit comments

Comments
 (0)