Claude Code hangs indefinitely on startup in non-git directories (regression since 2.1.31)
Bug Report - Critical Startup Hang
Severity: High - Claude Code becomes completely unusable when launched from any directory without a git repository.
Environment
- Claude Code version: 2.1.33 (also affects 2.1.31, 2.1.32)
- Last working version: 2.1.29
- OS: RHEL 8 (Linux 4.18.0-513.11.1.el8_9.x86_64)
- Node: v22.22.0
- Install method: native
Description
Starting Claude Code in any directory that is not a git repository causes the application to hang indefinitely with no output and no error message. The process never reaches the interactive prompt or responds to input. Users must manually kill the process.
This is a regression introduced in 2.1.31. Version 2.1.29 works correctly in non-git directories.
Steps to Reproduce
- Create a directory without git:
mkdir /tmp/test_no_git - Change to it:
cd /tmp/test_no_git - Run:
claude -p "say hello" - Observe: process hangs forever, no output, no error
Compare with a git directory:
cd /path/to/any/git/repo- Run:
claude -p "say hello" - Works correctly
Debug Log Evidence
The debug log clearly shows a 13-19 second gap between MCP server loading and session termination, with zero log output during the hang period:
2026-02-06T07:08:24.895Z [DEBUG] [claudeai-mcp] Fetching from https://api.anthropic.com/v1/mcp_servers?limit=1000
2026-02-06T07:08:25.623Z [DEBUG] [claudeai-mcp] Fetched 0 servers
-- 13 seconds of complete silence - NO debug output --
2026-02-06T07:08:38.946Z [DEBUG] Getting matching hook commands for SessionEnd with query: other
Isolation Testing Performed
To confirm this is not a configuration issue, I systematically disabled all possible causes:
| Test | Result |
|------|--------|
| Disabled custom statusLine command | Still hangs |
| Disabled ALL plugins (0 enabled) | Still hangs |
| Disabled ALL MCP servers (0 configured) | Still hangs |
| Minimal settings.json (empty config) | Still hangs |
| Same setup but in a git directory | Works fine |
This proves the bug is in Claude Code's core startup path, specifically in the non-git project root detection/initialization code path that runs after MCP config loading.
Expected Behavior
Claude Code should start normally in non-git directories, as it did in version 2.1.29.
Actual Behavior
Claude Code hangs indefinitely with no output or error message. The only way to recover is to kill the process.
Workaround
Run git init in the target directory before launching Claude Code.
Impact
This is a critical usability issue:
- Users cannot use Claude Code in any non-git directory (temp dirs, download folders, new project dirs, etc.)
- No error message means users cannot diagnose the problem themselves
- Forces unnecessary git initialization in directories that don't need version control
19 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
I'm seeing this issue as well. I didn't realize what the pattern was but it seems to be the same for me. Launching in non-git directories results in CC hanging (won't accept any input).
Major issue for me as well. If i run claude from the cli it works, however, when i mount the dir to a docker container to run cc in there it fails if the mounted dir is not a .git dir.
@justuskilianwolff @yeroc @zizhongx does this reproduce for you in a new git-initialized directory? I see "Run git init in the target directory before launching Claude Code." as a workaround, can anyone confirm this works?
Wondering if this might be about the "Trust this directory?" dialog rather than .git, and the git directory was one you'd used before.
Try 2.1.40, which has a related fix (edit: not released yet, coming soon)
@thomasballinger git init and then starting the container works. Didnt get a trust this directory, I assume its cached somewhere? Without git init I cant start it (2.1.44).
@thomasballinger it's possible it was related to the "Trust this directory?" prompt. I can no longer reproduce the issue with 2.1.45.
@thomasballinger I take it back. I still get the hang with 2.1.45. I get prompted to trust the folder, select yes and then get the usual banner and prompt but it won't accept any input. If I perform
git initin the directory and relaunch. I get the same prompt and then banner etc and no hang.Additional data point: standalone installer hangs, npm install works (same version)
Environment:
Findings:
I have two servers with the same Claude Code version (2.1.50) but different install methods:
| | Server A (HANGS) | Server B (WORKS) |
|---|---|---|
| Install method | Standalone (
~/.local/share/claude/) | npm via nvm (~/.nvm/versions/node/) || Node.js | v20.19.6 (bundled in SEA binary) | v20.19.4 (nvm) |
| Kernel | 4.18.0-553.87.1 | 4.18.0-553.71.1 |
| Non-git dir | Hard hang (Ctrl+C unresponsive) | Works fine |
Both servers are RHEL 8, accessed via SSH, same user, same
TERM=xterm-256color.Isolation testing on Server A (standalone, hangs):
settings.json({"model":"opus"}) → still hangsclaude -p "hello"(non-interactive) → works fineclaudein a git repo directory → works fineclaudein non-git directory → hard hang (terminal frozen, Ctrl+C doesn't work)Session logs show the process gets stuck after
SessionStarthook — the TUI never renders or accepts input.This suggests the standalone installer's bundled Node.js runtime may behave differently from system Node.js in non-git directory + interactive TUI initialization.
Just had the same issue on v2.1.62
I hit this on one of my old co-located machines as well with v2.1.63 just now. Took me forever to figure out the "git init" workaround.
Also, mine didn't hang, it exited right after showing the greeting screen, but before I could type anything.
I met the same problem on RHEL8 and RockyLinux 8.
And I found that it could be solved by upgrade the Linux kernel to 5.4.
I'm seeing this in 2.1.74+ on Windows with Git Bash and with VS Code, so it is no longer specifically Linux. The problem is getting worse. I've reverted to 2.1.29 and it works.
@madeupname Try to upgrade your Git (actually, git bash). I met a problem that solved by upgrading bash.
Can you see if this is still occurring on Claude Code 2.1.76?
@ant-kurt Great!
I upgraded to Claude Code v2.1.76 and tested again.
Running
claudein a non-git directory now works normally and the startup hang no longer occurs.Looks like the issue has been fixed. Thanks!
My previous comment was incorrect, it is working with:
Claude Code v2.1.87
GNU bash, version 5.2.37(1)-release (x86_64-pc-msys)
The problem was the new version didn't like entries in additionalDirectories.
This issue was fixed as of version 2.1.76.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.