Linux Terminal Bug Causes Mercurial Commands to Hang
The cursor froze on the screen, the Linux terminal silent, waiting. The Mercurial command should have executed in milliseconds. Instead, it stalled. This isn’t a minor hiccup. It’s a reproducible Linux terminal bug that can halt CI pipelines, delay deployments, and break automation scripts.
The bug appears when Mercurial interacts with certain terminal environments, especially those using non-standard I/O handling or pseudo-terminals. Engineers have traced it to how Mercurial spawns subprocesses and reads from stdin/stdout. In common shells like bash or zsh, the file descriptors can hang in a blocked state, causing hg commands to never complete. This issue surfaces most often in Docker containers, headless servers, and custom build agents running Linux distributions such as Ubuntu, Debian, or Fedora.
Symptoms include hg status or hg pull hanging indefinitely, even though CPU usage remains low. Strace will show the process stuck on a read() call against the terminal device. No network activity, no disk churn—just deadlock. Switching to a pure non-interactive environment can mask the problem, but it’s not a fix.
Workarounds include:
- Using the
--noninteractiveflag on Mercurial commands when possible. - Redirecting stdin from
/dev/nullto break the blocking read. - Executing commands through a fully detached shell process instead of an attached terminal.
- Upgrading Mercurial to a version that patches certain subprocess handling routines.
Permanent resolution will require upstream changes to how Mercurial interfaces with terminal I/O at the POSIX level. This means modifying the Python code that manages file descriptors in the hg CLI wrapper. Until that lands, the best defense is consistent environment configuration and automation scripts that force a clean, non-blocking terminal state before calling hg.
If this Linux terminal bug in Mercurial is breaking your workflow, don’t wait for upstream fixes. Test your environment with hoop.dev—see your Mercurial commands run clean and fast in minutes.