Conversation
We run some commands under a PTY so they behave like they do in an interactive terminal (colors, progress bars, etc.). However, this is still a *pseudo*-terminal and it doesn't necessarily provide a full/accurate terminal environment. Some libraries (for example Go's termenv) send OSC/CSI queries and wait for a response from the terminal. Our PTY doesn't emulate those responses, so they can block on a timeout if the program insists on probing capabilities. Previously, we tried to work around this by setting `TERM=dumb` in the environment, but that caused other issues (for example, some programs (e.g cargo), disable color entirely when they see `TERM=dumb`, even if the output is actually a terminal that supports color). We intentionally do not make the child a session leader/foreground process group here. When we did, termenv detected it as foreground and ran OSC probes, which then hung.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1586 +/- ##
==========================================
- Coverage 91.65% 91.65% -0.01%
==========================================
Files 93 93
Lines 18280 18277 -3
==========================================
- Hits 16755 16751 -4
- Misses 1525 1526 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes hanging issues with PTY process execution by removing the session leader setup and TERM=dumb environment variable setting. Previously, these workarounds were intended to prevent terminal capability probing issues, but they caused other problems (tools like cargo would disable colors entirely). The new approach simply avoids making the child a session leader, which prevents libraries like Go's termenv from detecting the process as foreground and attempting OSC probes that would hang.
Changes:
- Removed session leader setup for PTY child processes to prevent hanging on OSC/CSI capability probes
- Removed
TERM=dumbenvironment variable setting that caused color output to be disabled in some tools - Cleaned up unused
TERMconstant and import - Removed completed TODO comment in list command
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/prek/src/process.rs | Removed session leader setup and TERM=dumb workarounds; updated explanatory comments |
| crates/prek-consts/src/env_vars.rs | Removed unused TERM constant |
| crates/prek/src/cli/list.rs | Removed TODO comment that was already completed (full_id already includes project prefix) |
📦 Cargo Bloat ComparisonBinary size change: +0.00% (23.7 MiB → 23.7 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
Closes #1561
Previous fix: #1363
We run subcommands under a PTY so they behave like they do in an interactive terminal (colors, progress bars, etc.). However, this is still a pseudo-terminal and it doesn't necessarily provide a full/accurate terminal environment.
Some libraries (for example Go's termenv) send OSC/CSI queries and wait for a response from the terminal. Our PTY doesn't emulate those responses, so they can block on a timeout if the program insists on probing capabilities.
Previously, we tried to work around this by setting
TERM=dumbin the environment, but that caused other issues (for example, some programs (e.g cargo), disable color entirely when they seeTERM=dumb, even if the output is actually a terminal that supports color).We intentionally do not make the child a session leader/foreground process group here. When we did, termenv detected it as foreground and ran OSC probes, which then hung.