claude-code - 💡(How to fix) Fix [BUG] When a worktree is removed while its session is still open, all subsequent tool calls fail and the session becomes unrecoverable. [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48405Fetched 2026-04-16 07:01:05
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×4cross-referenced ×1

Error Message

Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy. at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632) at processTicksAndRejections (native:7:39) Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy. at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632) at processTicksAndRejections (native:7:39) Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy. at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632) at processTicksAndRejections (native:7:39) Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy. at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632) at processTicksAndRejections (native:7:39) Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.107: tool_use ids were found without tool_result blocks immediately after: toolu_01HJ9kr384q5rxCfbEuJai9U. Each tool_use block must have a corresponding tool_result block in the next message."},"request_id":"req_011Ca5C8879cZnqy1K4piGk5"} at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430) at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943) at processTicksAndRejections (native:7:39) Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.107: tool_use ids were found without tool_result blocks immediately after: toolu_01HJ9kr384q5rxCfbEuJai9U. Each tool_use block must have a corresponding tool_result block in the next message."},"request_id":"req_011Ca5C89rKdpcSWQGeBTk2G"} at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430) at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943) at processTicksAndRejections (native:7:39) CanceledError: canceled at W (/$bunfs/root/src/entrypoints/cli.js:113:7114) at abort (unknown) at v71 (/$bunfs/root/src/entrypoints/cli.js:1337:830) at abort (unknown) at v71 (/$bunfs/root/src/entrypoints/cli.js:1337:830) at abort (unknown) at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:16578:1968) at processTicksAndRejections (native:7:39) at request (/$bunfs/root/src/entrypoints/cli.js:115:2467) at processTicksAndRejections (native:7:39) Error: Request was aborted. at pE_ (/$bunfs/root/src/entrypoints/cli.js:1268:12089) at next (native:1:11) at sm7 (/$bunfs/root/src/entrypoints/cli.js:7918:9109) at next (native:1:11) at Hp7 (/$bunfs/root/src/entrypoints/cli.js:7923:11439) at processTicksAndRejections (native:7:39) Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997) at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106) at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139) at processTicksAndRejections (native:7:39) Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997) at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106) at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139) at processTicksAndRejections (native:7:39) Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997) at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106) at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139) at processTicksAndRejections (native:7:39) Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997) at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106) at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139) at processTicksAndRejections (native:7:39) Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997) at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106) at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139) at processTicksAndRejections (native:7:39) Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997) at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106) at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139) at processTicksAndRejections (native:7:39) Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997) at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106) at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139) at processTicksAndRejections (native:7:39)

Root Cause

This then caused a secondary failure: because the tool calls were erroring out rather than returning results, the API received tool_use blocks with no corresponding tool_result blocks, producing a 400 invalid_request_error (tool_use ids were found without tool_result blocks immediately after). The session then entered a crash loop and had to be abandoned.

Code Example

Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.107: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01HJ9kr384q5rxCfbEuJai9U. Each `tool_use` block must have a corresponding `tool_result` block in the next message."},"request_id":"req_011Ca5C8879cZnqy1K4piGk5"}
    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)
    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)
    at processTicksAndRejections (native:7:39)
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.107: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01HJ9kr384q5rxCfbEuJai9U. Each `tool_use` block must have a corresponding `tool_result` block in the next message."},"request_id":"req_011Ca5C89rKdpcSWQGeBTk2G"}
    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)
    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)
    at processTicksAndRejections (native:7:39)
CanceledError: canceled
    at W (/$bunfs/root/src/entrypoints/cli.js:113:7114)
    at abort (unknown)
    at v71 (/$bunfs/root/src/entrypoints/cli.js:1337:830)
    at abort (unknown)
    at v71 (/$bunfs/root/src/entrypoints/cli.js:1337:830)
    at abort (unknown)
    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:16578:1968)
    at processTicksAndRejections (native:7:39)
    at request (/$bunfs/root/src/entrypoints/cli.js:115:2467)
    at processTicksAndRejections (native:7:39)
Error: Request was aborted.
    at pE_ (/$bunfs/root/src/entrypoints/cli.js:1268:12089)
    at next (native:1:11)
    at sm7 (/$bunfs/root/src/entrypoints/cli.js:7918:9109)
    at next (native:1:11)
    at Hp7 (/$bunfs/root/src/entrypoints/cli.js:7923:11439)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

After force-removing a worktree (git worktree remove --force), the Claude Code harness continued trying to execute every tool call from the now-deleted worktree path. Every Bash, Read, Edit, and Glob call returned "Path '...' does not exist. Note: your current working directory is <deleted-worktree-path>" regardless of what directory was specified in the command itself — even cd ~ and absolute -C flags had no effect.

This then caused a secondary failure: because the tool calls were erroring out rather than returning results, the API received tool_use blocks with no corresponding tool_result blocks, producing a 400 invalid_request_error (tool_use ids were found without tool_result blocks immediately after). The session then entered a crash loop and had to be abandoned.

The worktree directory was correctly deleted from disk and git worktree prune completed cleanly in a new session — the issue is purely in the harness not updating its working directory when the underlying path disappears.

What Should Happen?

Claude should be chill about me working in main, after previously working in a work-tree.

Error Messages/Logs

Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.107: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01HJ9kr384q5rxCfbEuJai9U. Each `tool_use` block must have a corresponding `tool_result` block in the next message."},"request_id":"req_011Ca5C8879cZnqy1K4piGk5"}
    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)
    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)
    at processTicksAndRejections (native:7:39)
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.107: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01HJ9kr384q5rxCfbEuJai9U. Each `tool_use` block must have a corresponding `tool_result` block in the next message."},"request_id":"req_011Ca5C89rKdpcSWQGeBTk2G"}
    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)
    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)
    at processTicksAndRejections (native:7:39)
CanceledError: canceled
    at W (/$bunfs/root/src/entrypoints/cli.js:113:7114)
    at abort (unknown)
    at v71 (/$bunfs/root/src/entrypoints/cli.js:1337:830)
    at abort (unknown)
    at v71 (/$bunfs/root/src/entrypoints/cli.js:1337:830)
    at abort (unknown)
    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:16578:1968)
    at processTicksAndRejections (native:7:39)
    at request (/$bunfs/root/src/entrypoints/cli.js:115:2467)
    at processTicksAndRejections (native:7:39)
Error: Request was aborted.
    at pE_ (/$bunfs/root/src/entrypoints/cli.js:1268:12089)
    at next (native:1:11)
    at sm7 (/$bunfs/root/src/entrypoints/cli.js:7918:9109)
    at next (native:1:11)
    at Hp7 (/$bunfs/root/src/entrypoints/cli.js:7923:11439)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)

Steps to Reproduce

  1. Open a session in a repo and create a worktree (e.g. via EnterWorktree).
  2. Do some work in the worktree session — the harness sets its working directory to the worktree path.
  3. Without starting a new session, remove the worktree with git worktree remove --force <path> (or ask Claude to do it, as I did).
  4. Attempt any further tool call (Bash, Read, Edit, etc.) in the same session.

Expected: The harness detects that the working directory no longer exists and either recovers gracefully (e.g. falling back to the repo root) or surfaces a clear error prompting the user to start a new session.

Actual: Every tool call fails with "Path '...' does not exist" regardless of the command or any directory flags passed. The repeated tool failures cause the API to receive unmatched tool_use blocks, triggering a 400 invalid_request_error and a crash loop. The session cannot recover.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Claude 1.2581.0 (f10398) 2026-04-14T17:16:40.000Z

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue can be fixed by updating the harness to detect when the working directory no longer exists and recover gracefully, such as by falling back to the repo root.

Guidance

  • The harness should check if the working directory exists before executing tool calls, and if it doesn't, update the working directory to a valid path, such as the repo root.
  • The git worktree remove --force command is correctly removing the worktree directory, but the harness is not updating its internal state to reflect this change.
  • To mitigate the issue, the user can try starting a new session after removing the worktree, which should allow the harness to update its working directory correctly.
  • The error messages indicate that the harness is trying to access a non-existent path, which suggests that the issue is related to the harness's handling of the working directory.

Example

No code snippet is provided as the issue is related to the harness's internal state and behavior, rather than a specific code snippet.

Notes

The issue may be related to the harness's caching or internal state management, and updating the harness to handle this scenario correctly may require changes to its underlying architecture.

Recommendation

Apply a workaround by starting a new session after removing the worktree, until a fix is implemented to update the harness to handle this scenario correctly. This will allow the harness to update its working directory and prevent the error from occurring.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING