Skip to content

fix: prefer system conpty over sideloaded dll - #758

Closed
Melser wants to merge 1 commit into
herdrdev:masterfrom
Melser:fix/windows-prefer-system-conpty
Closed

Melser wants to merge 1 commit into
herdrdev:masterfrom
Melser:fix/windows-prefer-system-conpty

Conversation

@Melser

@Melser Melser commented Jun 23, 2026

Copy link
Copy Markdown

Summary

On Windows, portable-pty loads conpty.dll dynamically using the standard DLL search order, which includes PATH. When a terminal such as WezTerm is on PATH, its bundled conpty.dll gets sideloaded instead of the system ConPTY, which can break PTY creation in herdr's panes.

This change temporarily removes any PATH directory that contains a conpty.dll while calling openpty, so the system ConPTY is preferred. The original PATH is restored immediately afterward.

Implementation

  • openpty_preferring_system_conpty wraps native_pty_system().openpty(...).
  • ConptyPathGuard (RAII) strips offending PATH entries on install and restores the original PATH on drop — even on panic.
  • A global Mutex serializes the PATH mutation because PATH is process-global shared state and concurrent spawns would otherwise race.

Tests

Added Windows-only unit tests verifying the PATH filter removes directories containing conpty.dll and preserves directories without it.

🤖 Generated with Claude Code

On Windows, portable-pty resolves conpty.dll through the standard DLL search order, which includes PATH. When a terminal such as WezTerm is on PATH, its bundled conpty.dll gets sideloaded instead of the system ConPTY and can break PTY creation. Temporarily strip PATH entries that contain a conpty.dll while calling openpty so the system ConPTY is preferred, guarded by a global mutex and restored via RAII on drop.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@kangal-bot

Copy link
Copy Markdown
Collaborator

Hi @Melser, thanks for your interest in contributing!

New contributors need maintainer approval before opening PRs. This keeps review time focused on accepted work and avoids wasted effort.

Herdr is opinionated about how it should look, feel, and work. Feature requests, ideas, questions, contribution proposals, and product-direction checks belong in Discussions, not issues.

Next steps:

  1. If this is a feature or behavior change, open a Discussion describing what you want to change and why
  2. If the work is accepted, a maintainer may convert the discussion into an issue or create a new issue for it
  3. If this is a reproducible bug, open a bug report using the issue template
  4. Wait for maintainer approval on an accepted issue before opening a PR
    Maintainers approve first-time PR paths with /approve @your-github-username on the accepted issue.
  5. Keep it concise and write in your own voice

A discussion, issue, branch, or proposed implementation does not reserve the work and does not mean the PR path is approved.

This PR will be closed automatically. See https://github.com/ogulcancelik/herdr/blob/master/CONTRIBUTING.md for more details.

@kangal-bot kangal-bot closed this Jun 23, 2026
@Melser
Melser deleted the fix/windows-prefer-system-conpty branch June 25, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants