Claude Code exits with --print error when launched interactively in a non-git directory

Resolved 💬 4 comments Opened Feb 11, 2026 by pv-chorowitz Closed Mar 13, 2026

Description

Running claude interactively (no flags) in a directory that is not a git repository causes an immediate exit with code 1 and the error:

Error: Input must be provided either through stdin or as a prompt argument when using --print

The same command works correctly when launched from a child directory that is a git repository.

Environment

  • Claude Code v2.1.39
  • Linux (RHEL 8, kernel 4.18.0)
  • Installed via ~/.local/bin/claude

Steps to Reproduce

  1. Have a parent directory that is not a git repo (no .git/ at that level)
  2. That directory contains multiple subdirectories, each of which is an independent git repo
  3. Run claude (no arguments, no flags) from the parent directory
  4. Claude immediately exits with code 1

Running claude from any of the child git repositories works fine.

Analysis (via strace -f)

  • stdin is a TTY (ioctl(0, TCGETS, ...) succeeds) — this is not a piped/non-interactive session
  • No --print or -p flag is passed (execve shows ["claude"] with no additional args)
  • Startup proceeds normally through credential loading, MCP config, plugin/skill loading, LSP init, and OAuth
  • The debug log (~/.claude/debug/) shows SessionStart immediately followed by SessionEnd — the interactive REPL is never entered
  • The process writes the --print error, performs cleanup/telemetry, resets the terminal, and calls exit_group(1)

It appears that the run-mode detection logic incorrectly resolves to --print mode when the working directory is not inside a git repository, even though the session is interactive.

Expected Behavior

claude should enter interactive mode when stdin is a TTY, regardless of whether the working directory is a git repository.

View original on GitHub ↗

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