From 111ad645ee346b2e665245215a7c696c528b3ba6 Mon Sep 17 00:00:00 2001 From: slaguru666 Date: Wed, 15 Jul 2026 20:40:23 +0100 Subject: [PATCH] Fix memory dir path derivation on Windows install.sh and sync.sh derived PROJECT_KEY from the POSIX $HOME, which Git Bash reports as /c/Users/x -> "-c-Users-timev". Claude Code on Windows sees the native path and encodes it as "C--Users-timev", so memory files were copied to a directory Claude never reads. Convert $HOME with cygpath when available. Uses sed rather than bash substitution because a lone backslash in a glob pattern escapes the next character instead of matching a literal backslash. macOS and Linux keep the existing $HOME-based derivation. Co-Authored-By: Claude Opus 4.8 (1M context) --- install.sh | 14 +++++++++++--- sync.sh | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 8313829..b95a01a 100755 --- a/install.sh +++ b/install.sh @@ -8,9 +8,17 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CLAUDE_DIR="$HOME/.claude" USERNAME=$(whoami) -# Claude Code encodes the project dir by replacing "/" with "-". -# Derive from $HOME so it works on macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x). -PROJECT_KEY="${HOME//\//-}" +# Claude Code encodes the project dir by replacing the path separator with "-". +# macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x) encode the POSIX $HOME. +# On Windows, Claude Code sees the native path, so C:\Users\x -> C--Users-x. Git Bash +# reports $HOME as /c/Users/x, which would encode to the wrong key -- convert first. +if command -v cygpath >/dev/null 2>&1; then + # C:\Users\x -> C--Users-x (sed, not bash substitution: a lone "\" in a glob + # pattern escapes the next char instead of matching a literal backslash). + PROJECT_KEY="$(cygpath -w "$HOME" | sed 's/[\\:]/-/g')" +else + PROJECT_KEY="${HOME//\//-}" +fi MEMORY_DIR="$CLAUDE_DIR/projects/${PROJECT_KEY}/memory" echo "Installing Claude config for user: $USERNAME" diff --git a/sync.sh b/sync.sh index dcf0a90..3293a85 100755 --- a/sync.sh +++ b/sync.sh @@ -6,9 +6,17 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CLAUDE_DIR="$HOME/.claude" -# Claude Code encodes the project dir by replacing "/" with "-". -# Derive from $HOME so it works on macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x). -PROJECT_KEY="${HOME//\//-}" +# Claude Code encodes the project dir by replacing the path separator with "-". +# macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x) encode the POSIX $HOME. +# On Windows, Claude Code sees the native path, so C:\Users\x -> C--Users-x. Git Bash +# reports $HOME as /c/Users/x, which would encode to the wrong key -- convert first. +if command -v cygpath >/dev/null 2>&1; then + # C:\Users\x -> C--Users-x (sed, not bash substitution: a lone "\" in a glob + # pattern escapes the next char instead of matching a literal backslash). + PROJECT_KEY="$(cygpath -w "$HOME" | sed 's/[\\:]/-/g')" +else + PROJECT_KEY="${HOME//\//-}" +fi MEMORY_DIR="$CLAUDE_DIR/projects/${PROJECT_KEY}/memory" MSG="${1:-sync config}"