[BUG] Claude code with version > 2.1.29 exits immediately when run in non-git directory
Resolved 💬 4 comments Opened Feb 21, 2026 by netgull Closed Apr 8, 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?
Claude Code version 2.1.39 crashes immediately when run in a directory that is not a git repository, while version 2.1.29 works correctly in the same scenario.
Environment
- OS: Linux 4.18.0-553.104.1.el8_10.x86_64
- Broken version: 2.1.39
- Working version: 2.1.29
- Installation method: native
What Should Happen?
- Create a git directory:
mkdir ~/test_with_git && cd ~/test_with_git && git init - Run:
claude - Result: Works fine
Error Messages/Logs
Steps to Reproduce
- Create a non-git directory:
mkdir ~/test_no_git && cd ~/test_no_git - Run:
claude - Expected: Claude Code starts normally
- Actual: Process crashes immediately with no error message
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.29
Claude Code Version
2.1.39
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
Root Cause Analysis
Using strace to trace system calls, we identified that v2.1.39 removed pre-flight git safety checks that v2.1.29 had:
Version 2.1.29 (Working)
1. git rev-parse --is-inside-work-tree # Checks if in git repo
2. git remote get-url origin # Checks if origin exists
3. git worktree list # Lists worktrees
4. git pull origin HEAD # Only runs if checks pass
Version 2.1.39 (Broken)
1. git pull origin HEAD # NO pre-flight checks - fails with exit 128
When git pull runs in a non-git directory, it fails with exit code 128:
fatal: not a git repository (or any parent up to mount point /)
The error handling for this failure causes the process to crash.
Impact
Users cannot use Claude Code in:
- New projects before running
git init - Non-code directories
- Any directory tree without git
Suggested Fix
Re-add the pre-flight check from v2.1.29:
git rev-parse --is-inside-work-tree 2>/dev/null
Or handle git exit code 128 gracefully instead of crashing.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗