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) <noreply@anthropic.com>
This commit is contained in:
2026-07-15 20:40:23 +01:00
co-authored by Claude Opus 4.8
parent 88e36dc8a6
commit 111ad645ee
2 changed files with 22 additions and 6 deletions
+11 -3
View File
@@ -8,9 +8,17 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CLAUDE_DIR="$HOME/.claude" CLAUDE_DIR="$HOME/.claude"
USERNAME=$(whoami) USERNAME=$(whoami)
# Claude Code encodes the project dir by replacing "/" with "-". # Claude Code encodes the project dir by replacing the path separator with "-".
# Derive from $HOME so it works on macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x). # macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x) encode the POSIX $HOME.
PROJECT_KEY="${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" MEMORY_DIR="$CLAUDE_DIR/projects/${PROJECT_KEY}/memory"
echo "Installing Claude config for user: $USERNAME" echo "Installing Claude config for user: $USERNAME"
+11 -3
View File
@@ -6,9 +6,17 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CLAUDE_DIR="$HOME/.claude" CLAUDE_DIR="$HOME/.claude"
# Claude Code encodes the project dir by replacing "/" with "-". # Claude Code encodes the project dir by replacing the path separator with "-".
# Derive from $HOME so it works on macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x). # macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x) encode the POSIX $HOME.
PROJECT_KEY="${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" MEMORY_DIR="$CLAUDE_DIR/projects/${PROJECT_KEY}/memory"
MSG="${1:-sync config}" MSG="${1:-sync config}"