-
Notifications
You must be signed in to change notification settings - Fork 176
Fix windows claude cli #18
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Fixes Windows-specific issues with Claude CLI execution by implementing a platform-aware adapter pattern. The main problem was that subprocess.run couldn't directly execute PowerShell scripts (.ps1) on Windows, causing "Claude CLI not installed" errors.
- Implements a PlatformAdapter class for cross-platform Claude CLI command execution
- Adds comprehensive testing utilities with Windows-specific mocking capabilities
- Updates main audit logic to use platform-aware command execution
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
File | Description |
---|---|
claudecode/platform_utils.py | New platform adapter that handles Windows PowerShell/CMD execution while maintaining Unix compatibility |
claudecode/test_utils.py | Comprehensive testing utilities with Windows environment simulation and Claude CLI mocking |
claudecode/github_action_audit.py | Updated to use platform adapter for robust cross-platform Claude CLI validation |
README.md | Added Windows-specific installation and troubleshooting documentation |
|
||
1. Install Node.js (v18 or later) and npm: | ||
- Download from https://nodejs.org or use nvm-windows. | ||
2. Install the Claude CLI:npm install -g @anthropic-ai/claude-code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The installation command is missing proper formatting and line breaks. It should be formatted as a code block for clarity.
2. Install the Claude CLI:npm install -g @anthropic-ai/claude-code | |
2. Install the Claude CLI: | |
```bash | |
npm install -g @anthropic-ai/claude-code |
Copilot uses AI. Check for mistakes.
|
||
4. Set PowerShell execution policy:Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned | ||
5. Verify installation:claude --version | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PowerShell commands are not properly formatted as code blocks and appear as continuous text. These should be separate code blocks with proper formatting.
2. Install the Claude CLI: | |
```powershell | |
npm install -g @anthropic-ai/claude-code |
-
Add npm global directory to PATH:
$npmPath = npm config get prefix [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";$npmPath", "User")
-
Set PowerShell execution policy:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
-
Verify installation:
claude --version
Copilot uses AI. Check for mistakes.
|
||
4. Set PowerShell execution policy:Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned | ||
5. Verify installation:claude --version | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing proper formatting for the PowerShell command. Should be in a code block for better readability.
4. Set PowerShell execution policy: | |
```powershell | |
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned |
-
Verify installation:
claude --version
Copilot uses AI. Check for mistakes.
|
||
4. Set PowerShell execution policy:Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned | ||
5. Verify installation:claude --version | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command should be formatted as a code block for consistency with documentation standards.
5. Verify installation: | |
claude --version
Copilot uses AI. Check for mistakes.
|
||
Expected output: 1.0.71 (Claude Code) or similar. | ||
|
||
Troubleshooting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing proper markdown heading formatting. Should be '### Troubleshooting' to maintain documentation hierarchy.
Troubleshooting | |
### Troubleshooting |
Copilot uses AI. Check for mistakes.
return claude_cmd | ||
except OSError as e: | ||
logger.debug(f"Error checking path {npm_path}: {e}") | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The continue statement is unnecessary here since it's at the end of the loop. The loop will naturally continue to the next iteration.
continue |
Copilot uses AI. Check for mistakes.
Hello, While running pytest locally on Windows, I encountered two issues:
|
The Claude Code Security Reviewer project has a Windows-specific issue where the test test_anthropic_api_key_handling failed due to subprocess.run not handling the PowerShell script claude.ps1 correctly, resulting in a "Claude CLI not installed" error. Resolved this by implementing a PlatformAdapter class in platform_utils.py, which uses platform-aware command execution to invoke claude.ps1 via powershell.exe or claude.cmd on Windows, while maintaining compatibility with Linux/macOS. Comprehensive tests in test_utils.py and updated documentation in README.md ensure the fix is robust, preventing other Windows users from encountering this issue.