Claude Code fails in Git Bash with path errors like:
Error: /usr/bin/bash: line 1: C:UsersDavid.WeiAppDataLocalTemp/claude-shell-snapshot-6ea5: No such file or directory
Root cause: os.tmpdir()
returns Windows paths, Git Bash expects Unix paths.
Solution: Patch the CLI directly with sed.
# Create ~/bin/c
#!/bin/bash
REAL_CLAUDE=$(which claude)
basedir=$(dirname "$REAL_CLAUDE")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
CLAUDE_DIR="$basedir/node_modules/@anthropic-ai/claude-code"
CLI_FILE="$CLAUDE_DIR/cli.js"
BACKUP_FILE="$CLI_FILE.original"
# Backup once
if [ ! -f "$BACKUP_FILE" ]; then
cp "$CLI_FILE" "$BACKUP_FILE"
fi
# Patch and run
cp "$BACKUP_FILE" "$CLI_FILE"
sed -i 's/\b\w\+\.tmpdir()/\"\/tmp\"/g' "$CLI_FILE"
cd "$CLAUDE_DIR"
exec node "cli.js" "$@"
chmod +x ~/bin/c
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
Now works:
c doctor
c --version
The regex catches minified variable names. Patches fresh every run, so updates don't break it.
Can't paste images to Claude Code in your Linux terminal? Here's a one-minute fix for Kitty users.
The Fix
1. Create the script (~/bin/clip2path
):
#!/usr/bin/env bash
set -e
if [ -n "$WAYLAND_DISPLAY" ]; then
types=$(wl-paste --list-types)
if grep -q '^image/' <<<"$types"; then
ext=$(grep -m1 '^image/' <<<"$types" | cut -d/ -f2 | cut -d';' -f1)
file="/tmp/clip_$(date +%s).${ext}"
wl-paste > "$file"
printf '%q' "$file" | kitty @ send-text --stdin
else
wl-paste --no-newline | kitty @ send-text --stdin
fi
elif [ -n "$DISPLAY" ]; then
types=$(xclip -selection clipboard -t TARGETS -o)
if grep -q '^image/' <<<"$types"; then
ext=$(grep -m1 '^image/' <<<"$types" | cut -d/ -f2 | cut -d';' -f1)
file="/tmp/clip_$(date +%s).${ext}"
xclip -selection clipboard -t "image/${ext}" -o > "$file"
printf '%q' "$file" | kitty @ send-text --stdin
else
xclip -selection clipboard -o | kitty @ send-text --stdin
fi
fi
2. Make executable:
chmod +x ~/bin/clip2path
3. Add to ~/.config/kitty/kitty.conf
:
allow_remote_control yes
listen_on unix:/tmp/kitty-socket
map ctrl+v launch --type=background --allow-remote-control --keep-focus ~/bin/clip2path
4. Install dependencies:
# X11 users only
sudo apt install xclip
5. Restart Kitty
6. Setup automatic cleanup (optional):
# Add to crontab to clean old screenshots daily
(crontab -l 2>/dev/null; echo "0 3 * * * find /tmp -name 'clip_*' -type f -mtime +1 -delete") | crontab -
Now Ctrl+V
automatically saves clipboard images as temp files and pastes their paths. Works on both Wayland and X11.
Got a Windows dev VM where you can't install WSL? Here's how to get Claude Code working with just Git Bash.
The Fix
Add these to your .bashrc
:
export NPM_CONFIG_IGNORE_SCRIPTS=true
export SHELL=/c/Program\ Files/Git/bin/bash.exe
Then:
source ~/.bashrc
npm install -g @anthropic-ai/claude-code
Done.
Why It Works
Git Bash provides enough Unix-like environment for Claude Code. The SHELL
export tells it where to find bash, and NPM_CONFIG_IGNORE_SCRIPTS
prevents install script issues.
Caveats
This is a workaround, not official support. Works fine in my vm, let me know if it also works on your machine!
Tested on Windows Server 2022 with Git for Windows 2.50.0.windows.1