Claude Code hangs indefinitely on startup in non-git directories (regression since 2.1.31)

Resolved 💬 19 comments Opened Feb 6, 2026 by zizhongx Closed Apr 17, 2026
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

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

  1. Create a directory without git: mkdir /tmp/test_no_git
  2. Change to it: cd /tmp/test_no_git
  3. Run: claude -p "say hello"
  4. Observe: process hangs forever, no output, no error

Compare with a git directory:

  1. cd /path/to/any/git/repo
  2. Run: claude -p "say hello"
  3. 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

View original on GitHub ↗

19 Comments

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/23195
  2. https://github.com/anthropics/claude-code/issues/23164
  3. https://github.com/anthropics/claude-code/issues/23016

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

yeroc · 5 months ago

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).

justuskilianwolff · 5 months ago

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.

thomasballinger · 5 months ago

@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.

thomasballinger · 5 months ago

Try 2.1.40, which has a related fix (edit: not released yet, coming soon)

justuskilianwolff · 4 months ago

@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).

yeroc · 4 months ago

@thomasballinger it's possible it was related to the "Trust this directory?" prompt. I can no longer reproduce the issue with 2.1.45.

yeroc · 4 months ago

@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 init in the directory and relaunch. I get the same prompt and then banner etc and no hang.

dev-minjae · 4 months ago

Additional data point: standalone installer hangs, npm install works (same version)

Environment:

  • OS: RHEL 8 (kernel 4.18.0-553.87.1.el8_10.x86_64)
  • Claude Code: 2.1.50
  • Connection: SSH

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):

  • Disabled all hooks, plugins, statusLine → still hangs
  • Minimal settings.json ({"model":"opus"}) → still hangs
  • claude -p "hello" (non-interactive) → works fine
  • claude in a git repo directory → works fine
  • claude in non-git directory → hard hang (terminal frozen, Ctrl+C doesn't work)

Session logs show the process gets stuck after SessionStart hook — 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.

vitusbenson · 4 months ago

Just had the same issue on v2.1.62

rlerdorf · 4 months ago

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.

PMExtra · 4 months ago

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.

madeupname · 4 months ago

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.

PMExtra · 4 months ago
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.

ant-kurt collaborator · 4 months ago

Can you see if this is still occurring on Claude Code 2.1.76?

PMExtra · 4 months ago

@ant-kurt Great!

I upgraded to Claude Code v2.1.76 and tested again.

Running claude in a non-git directory now works normally and the startup hang no longer occurs.

Looks like the issue has been fixed. Thanks!

madeupname · 3 months ago

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.

claude[bot] contributor · 3 months ago

This issue was fixed as of version 2.1.76.

github-actions[bot] · 2 months ago

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.