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 <noreply@anthropic.com>
This commit is contained in:
Ashwin Bhat 2025-11-18 20:47:26 -08:00 committed by GitHub
parent 35dd5b4bcc
commit 58cfffc623
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,12 +20,21 @@ def get_cli_version() -> str:
def find_installed_cli() -> Path | None:
"""Find the installed Claude CLI binary."""
# Check common installation locations
locations = [
Path.home() / ".local/bin/claude",
Path("/usr/local/bin/claude"),
Path.home() / "node_modules/.bin/claude",
]
system = platform.system()
if system == "Windows":
# Windows installation locations (matches test.yml: $USERPROFILE\.local\bin)
locations = [
Path.home() / ".local" / "bin" / "claude.exe",
Path(os.environ.get("LOCALAPPDATA", "")) / "Claude" / "claude.exe",
]
else:
# Unix installation locations
locations = [
Path.home() / ".local" / "bin" / "claude",
Path("/usr/local/bin/claude"),
Path.home() / "node_modules" / ".bin" / "claude",
]
# Also check PATH
cli_path = shutil.which("claude")
@ -42,18 +51,43 @@ def find_installed_cli() -> Path | None:
def download_cli() -> None:
"""Download Claude Code CLI using the official install script."""
version = get_cli_version()
system = platform.system()
print(f"Downloading Claude Code CLI version: {version}")
# Download and run install script
install_script = "curl -fsSL https://claude.ai/install.sh | bash"
if version != "latest":
install_script = f"curl -fsSL https://claude.ai/install.sh | bash -s {version}"
# Build install command based on platform
if system == "Windows":
# Use PowerShell installer on Windows
if version == "latest":
install_cmd = [
"powershell",
"-ExecutionPolicy",
"Bypass",
"-Command",
"irm https://claude.ai/install.ps1 | iex",
]
else:
install_cmd = [
"powershell",
"-ExecutionPolicy",
"Bypass",
"-Command",
f"& ([scriptblock]::Create((irm https://claude.ai/install.ps1))) {version}",
]
else:
# Use bash installer on Unix-like systems
if version == "latest":
install_cmd = ["bash", "-c", "curl -fsSL https://claude.ai/install.sh | bash"]
else:
install_cmd = [
"bash",
"-c",
f"curl -fsSL https://claude.ai/install.sh | bash -s {version}",
]
try:
subprocess.run(
install_script,
shell=True,
install_cmd,
check=True,
capture_output=True,
)