fix: correct Windows path encoding/resolution in cvfs#41
Open
hen-corix wants to merge 1 commit into
Open
Conversation
On Windows, path handling had several issues that caused claude-mv, claude-ls, and claude-clean to fail or misidentify project directories. - normalize_sep: convert backslashes to forward slashes uniformly - get_home: prefer USERPROFILE over HOME on Win32 (Git Bash sets HOME to an MSYS2 virtual path like /c/Users/foo that Win32 APIs can't resolve) - msys2_to_win: convert Git Bash MSYS2 drive-mount paths (/d/foo) to proper Windows paths (D:/foo) before encoding - resolve_path: handle Windows absolute paths (C:/...) correctly and normalize Unix.realpath output which may return backslashes on Win32 - project_path: match Claude Code's encoding — replace any char outside [a-zA-Z0-9-] with '-' (previously only /, \, : were replaced, missing underscores, spaces, and other ASCII special chars) - get_cwd_from_jsonl / get_project_path_from_dir: read the actual cwd from JSONL conversation files instead of trying to reverse the lossy encoded directory name (hyphens in dir names are indistinguishable from encoded path separators) - Replace all Sys.getenv "HOME" with get_home () throughout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_home(): preferUSERPROFILEoverHOMEon Win32 — Git Bash setsHOMEto an MSYS2 virtual path (e.g./c/Users/foo) that native Win32 file APIs can't resolvemsys2_to_win(): convert Git Bash MSYS2 drive-mount paths (/d/workspace/foo) to proper Windows paths (D:/workspace/foo) before processingresolve_path(): handle Windows absolute paths (C:/...) correctly; normalizeUnix.realpathoutput which may return backslashes on Win32project_path(): match Claude Code's actual encoding — replace any character outside[a-zA-Z0-9-]with-(previously only/,\,:were replaced, missing underscores, spaces, and other chars)get_cwd_from_jsonl()/get_project_path_from_dir(): read the realcwdfrom JSONL conversation files instead of trying to reverse-decode the encoded directory name (which is lossy — hyphens in folder names are indistinguishable from encoded path separators)Sys.getenv "HOME"withget_home()throughoutContext
These fixes address three bugs on Windows:
claude-mvalways reported "Error: No conversation found"claude-lsreported "No conversations found in ."claude-ls/claude-cleanfailed for project paths containing hyphens, uppercase letters, underscores, or spacesTest plan
claude-lsin a Windows project directory returns conversationsclaude-lsin a path with underscores (e.g.D:\workspace\My_Project) finds the correct Claude project directoryclaude-lswith a Git Bash MSYS2 path argument (e.g./d/workspace/foo) resolves correctlyclaude-cleanshows correct project paths (not mangled by lossy hyphen substitution)claude-mvsuccessfully finds and moves conversations on Windows🤖 Generated with Claude Code