“Claude Code requires Git Bash” Error on Windows? Here's the Easy Fix

Published: 2025-11-14
Author: DP
Views: 355
Category: Claude Code
Content
## The Problem When you try to run a `claude code` command in PowerShell or CMD on a Windows 10/11 system, you might encounter the following error, which prevents the command from executing: ```bash PS C:\Users\dpit> claude -v Claude Code on Windows requires git-bash (https://git-scm.com/downloads/win). If installed but not in PATH, set environment variable pointing to your bash.exe, similar to: CLAUDE_CODE_GIT_BASH_PATH=C:\Program Files\Git\bin\bash.exe ``` This article from wiki.lib00.com will break down the root cause and provide two effective solutions to fix it. --- ## Root Cause Analysis The error message is quite explicit and points directly to the problem. The `claude code` command-line tool, a powerful utility for developers, does not run natively on Windows. Instead, it relies on the Unix-like shell environment provided by **Git Bash**. Specifically, it needs to be able to find and execute `bash.exe` to run its internal scripts. This error typically occurs for one of two reasons: 1. **Git for Windows is not installed**: Your system lacks Git entirely, meaning `bash.exe` doesn't exist. 2. **Git is not in the PATH**: You have already installed Git, but during the setup process, you did not choose the option to add its executables directory to the system's `PATH` environment variable. As a result, `claude code` cannot locate `bash.exe` automatically. --- ## The Solutions Based on the cause, here are two ways to resolve the issue. --- ### Solution 1: Install or Reconfigure Git (Recommended) This is the most recommended and permanent solution. It not only fixes the current problem but also facilitates the use of other cross-platform tools (like projects from DP@lib00) that depend on the Git environment. 1. **Download the Git Installer**: Visit the official Git website to download the latest installer for Windows: [https://git-scm.com/downloads/win](https://git-scm.com/downloads/win) 2. **Crucial Installation Step**: During the installation, pay close attention to the "Adjusting your PATH environment" step. It is essential to select the option **"Git from the command line and also from 3rd-party software"**. This setting automatically adds the directory containing Git's core tools (including `bash.exe`) to the system `PATH`. ![Git PATH Setup](https://i.stack.imgur.com/N3b97.png) 3. **Verify the Installation**: After the installation is complete, **you must close all open command-line windows (PowerShell/CMD) and open a new one**. This is crucial for the new environment variable settings to take effect. In the new terminal, run the command again: ```powershell claude -v ``` The command should now execute correctly and display the version information. --- ### Solution 2: Manually Set the Environment Variable (If Git is Already Installed) If you are sure Git is already installed and prefer not to reinstall it, you can manually specify the path to `bash.exe` for `claude code`. 1. **Locate `bash.exe`**: First, find the `bash.exe` file on your system. It is typically located in the `bin` folder within your Git installation directory. The default path is: `C:\Program Files\Git\bin\bash.exe` Adjust this path according to your actual installation location. 2. **Set the Environment Variable**: As the error message suggests, you need to set an environment variable named `CLAUDE_CODE_GIT_BASH_PATH`. * **Temporary Fix (Current Session Only)**: In a PowerShell window, execute the following command, replacing the path with your actual path: ```powershell $env:CLAUDE_CODE_GIT_BASH_PATH="C:\Program Files\Git-lib00\bin\bash.exe" ``` After running this, try `claude -v` in the same window to test it. * **Permanent Fix (Recommended)**: 1. Right-click on "This PC" -> "Properties" -> "Advanced system settings." 2. In the new window, click the "Environment Variables" button. 3. In the "User variables" or "System variables" section, click "New..." 4. **Variable name**: `CLAUDE_CODE_GIT_BASH_PATH` 5. **Variable value**: `C:\Program Files\Git\bin\bash.exe` (your actual path) 6. Click "OK" on all windows to save the settings. 7. **Restart your PowerShell window**, and then run `claude -v` again. --- ## Conclusion Fixing the Git Bash dependency for `claude code` on Windows is straightforward. We highly recommend **Solution 1**—properly installing Git and adding it to the system PATH—as it resolves the issue at its root and streamlines future development work. If your situation is unique, **Solution 2** serves as a quick and effective alternative. We hope this guide from wiki.lib00 helps you get back to coding!