[BUG] Claude Code Windows can silently use WSL instead of gitbash leading to subtle Windows incompetence of agent
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code Windows integates with gitbash via the command name bash. Unfortunately WSL also assumes this command as an alias when installed meaning that in this case shell commands are run using WSL and not gitbash.
This kind of works for many use cases, except when dealing with Windows toolchains, Windows installed utilities etc. Most commands run by the agent will take place inside WSL since it starts in WSL bash. The agent will run Powershell commands as powershell.exe -C "XXXXXX" when something obviously windows needs to to be done and that will impact / reflect your Windows machine setup. The problem comes when the agent is asked to carry out something that works with Windows but sounds like it plausibly apply to WSL, it can mix WSL and Powershell+Windows across commands, and get confused at the inconsistency it experiences in the process.
One example was that I had a .NET Framework 4.8 app, which had a broken local setup to build - I was missing the necessary specific versions of MSBuild, and those versions were Windows only, not cross platform like later versions of .NET. Claude could not solve this problem because it kept trying to install on the wrong platform, or install on the right platform and then check for successful install on the wrong platform.
It took me a whole day to work out what was going wrong here, because the symptoms were quite subtle and I was not expecting anything to be run outside of Windows. This issue could cause some wasted time so I thought I will make sure others know about it :)
What Should Happen?
Claude should reliably and consistently leverage gitbash for Windows to avoid this subtle agent incompetence. This could take the form of a more direct dependence rather than using the bash alias
Error Messages/Logs
Steps to Reproduce
- On a fresh Windows machine, install Git + gitbash
- Install WSL with Ubuntu 24.04
- Install Claude Code for Windows
- In a new session in Claude Code Windows, ask Claude to install dotnet
- Claude will install dotnet inside WSL
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.42
Platform
Google Vertex AI
Operating System
Windows
Terminal/Shell
Other
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗