Session resume picker fails with git worktree relative paths
Bug description
claude -r (interactive session picker) fails to find any sessions when git worktrees use relative paths (worktree.useRelativePaths = true).
Sessions exist on disk and can be resumed by passing the session ID directly (claude -r <uuid>), but the interactive picker shows "No conversations found to resume."
The /rename + claude -r <custom-name> flow is also broken for the same reason.
Steps to reproduce
- Configure git to use relative worktree paths:
``bash``
git config --global worktree.useRelativePaths true
- Create a worktree:
``bash``
cd ~/Projects/my-repo
git worktree add ../my-repo-branch feature-branch
- Start Claude Code in the worktree directory, have a conversation, then exit
- Run
claude -r— no sessions are listed - Run
claude -r <session-uuid>— works fine
Root cause
The dd() function (worktree path discovery) runs git worktree list --porcelain and uses the output paths as-is. With worktree.useRelativePaths = true, linked worktrees are listed with relative paths:
worktree /home/user/Projects/my-repo ← absolute (main worktree)
worktree ../../../my-repo-branch ← relative (linked worktree)
This causes two failures:
- CWD matching fails: The function checks
cwd === worktreePathbut/home/user/Projects/my-repo-branch!==../../../my-repo-branch, so the current project isn't identified.
- Session directory lookup fails: Worktree paths are encoded via
path.replace(/[^a-zA-Z0-9]/g, "-")to derive session directory names. The relative path../../../my-repo-branchencodes to-------my-repo-branchinstead of the correct-home-user-Projects-my-repo-branch, so existing session files are never found.
Expected behavior
claude -r should resolve relative worktree paths to absolute paths before using them for CWD matching and session directory lookup. Something like:
const worktreePaths = rawPaths.map(p => path.resolve(cwd, p));
Or equivalently, resolve relative to the main worktree's directory.
Environment
- Claude Code version: 2.1.37
- OS: Linux (devcontainer)
- Git version: 2.47.2
worktree.useRelativePaths:true(global)
Workaround
Disable relative worktree paths and repair:
git config worktree.useRelativePaths false
git worktree repair
This converts worktree references back to absolute paths, but sacrifices portability across machines with different mount points.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗