Skip to content

fix(claude): resolve symlinks in the WorktreeCreate hook's path - #4814

Merged
max-sixty merged 1 commit into
mainfrom
fix/issue-4812
Nov 16, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/issue-4812

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

The Claude Code WorktreeCreate hook printed the path field from wt switch --format=json without changing it. For a new worktree, that is the templated worktree-path. When the template puts worktrees under a symlinked directory inside the repository, such as {{ repo_path }}/.worktrees/… with .worktrees linked elsewhere, the printed path goes through that link. Claude Code 2.1.325 refuses that kind of answer (CHANGELOG: "Changed EnterWorktree to refuse a WorktreeCreate hook path that goes through a symlink inside the project; have the hook print the real path"). The hook now resolves the path with dunce::canonicalize before printing it. operational_worktree_path in switch.rs already resolves paths for existing worktrees the same way.

test_claude_hook_worktree_create_resolves_symlink links .worktrees to a directory outside the repository and checks the path the hook prints. It failed before the change (…/repo/.worktrees/agent-task) and passes after it (…/real-worktrees/agent-task). The existing WorktreeCreate tests still pass. I couldn't check the change against Claude Code 2.1.325 itself. The refusal described above comes from its changelog.

The JSON output of wt switch --format=json is unchanged. Whether it should report resolved paths in general is a separate question.

Closes #4812 — automated triage

Claude Code 2.1.325 refuses a WorktreeCreate answer that goes through a
symlink inside the project. The hook printed the templated path from
wt switch --format=json, which does when worktree-path places worktrees
under a symlinked directory in the repository. It now prints the
canonical path.

Closes #4812
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code 2.1.325 refuses a WorktreeCreate path through a symlink inside the project; the wt hook prints the unresolved path

2 participants