[BUG] Running session breaks after Homebrew upgrade due to stale binary path

Resolved 💬 3 comments Opened Jan 13, 2026 by AbdelrahmanHafez Closed Feb 27, 2026

Preflight Checklist

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

What's Wrong?

When Claude Code is installed via Homebrew and a session is running (e.g., v2.1.5), upgrading to a newer version in another terminal (brew upgrade claude-code) causes the running session to error out when using tools that spawn subprocesses (like Search/Grep).

The error occurs because the old version's binary path no longer exists after the upgrade:

Error: ENOENT: no such file or directory, posix_spawn '/opt/homebrew/Caskroom/claude-code/2.1.5/claude'

The session becomes unusable and must be restarted.

What Should Happen?

Running sessions should continue to work after a Homebrew upgrade, or gracefully handle the version change. Possible solutions:

  • Homebrew installation could preserve the running binary until sessions using it terminate
  • Claude could detect this condition and suggest restarting
  • Subprocess spawning could resolve the current binary path dynamically rather than using a cached path

Error Messages/Logs

⏺ Search(pattern: "middleware.*false|middleware.*pre|SkipMiddleware", path: "test/types", output_mode: "content")
  ⎿  Error: ENOENT: no such file or directory, posix_spawn '/opt/homebrew/Caskroom/claude-code/2.1.5/claude'

Steps to Reproduce

  1. Install an older version of Claude Code:

``bash
cd $(brew --repository homebrew/homebrew-cask)/Casks/c
git log --oneline claude-code.rb | head -5 # find commit for 2.1.5
git checkout <commit-hash> -- claude-code.rb
brew reinstall --cask claude-code
git checkout HEAD -- claude-code.rb
``

  1. Start a Claude Code session in one terminal
  1. In a separate terminal, upgrade to latest:

``bash
brew upgrade --cask claude-code
``

  1. In the original session, use a tool that spawns a subprocess (Search, Grep, etc.)
  1. Observe the ENOENT error referencing the old version path

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.6 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

This appears to be a Homebrew Cask-specific issue. The Cask installation creates version-specific directories under /opt/homebrew/Caskroom/claude-code/<version>/, and when upgraded, the old directory is removed while the running process still references it.

The issue affects any tool that spawns subprocesses using the original binary path. Regular text responses continue to work since they don't require spawning the binary.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗