Skip to content

fix(environment): keep the package importable without unix sockets - #621

Open
mikhail-koviazin wants to merge 2 commits into
hud-evals:mainfrom
mikhail-koviazin:fix/import-without-unix-sockets
Open

fix(environment): keep the package importable without unix sockets#621
mikhail-koviazin wants to merge 2 commits into
hud-evals:mainfrom
mikhail-koviazin:fix/import-without-unix-sockets

Conversation

@mikhail-koviazin

@mikhail-koviazin mikhail-koviazin commented Aug 27, 2026

Copy link
Copy Markdown

Why

import hud fails on Windows, before any of the code involved is used:

File "hud\environment\egress.py", line 529, in <module>
    class _UnixServer(socketserver.ThreadingUnixStreamServer):
AttributeError: module 'socketserver' has no attribute 'ThreadingUnixStreamServer'

Two things run at module scope on a platform that has neither of them: the _UnixServer subclass in hud/environment/egress.py, and import pty in hud/environment/namespace.py. hud/__init__.py imports clients, which imports environment, so both run on any import of the package, and every command goes down with them. That includes the ones that never go near a workspace: hud --version, hud set, hud jobs.

This is a regression. hud==0.6.12 imports on Windows and 0.6.13 onwards does not. _UnixServer arrived in 812ae12, and the unguarded import pty in d62acae, which moved namespace hosting out of workspace.py, where that same import had been behind a platform guard since 50b2acc.

The package otherwise treats Windows as somewhere it runs. workspace.py guards fcntl, pty and termios, and has a cmd.exe session path; hud/cli/__init__.py rewraps the console so Rich can print on cp1252; six test modules carry skipif(sys.platform == "win32"). hud/environment/tests/test_workspace.py marks its whole module that way, but the marker never gets to apply: collecting the file imports egress, which raises first.

What

Both now sit behind the sys.platform != "win32" guard workspace.py already uses.

This does not make workspaces run on Windows, and nothing about the unix machinery changes. namespace.py still opens AF_UNIX sockets, so starting an environment there still fails, at the point of use rather than at import. That is where the rest of the package's unix-only paths already fail.

It also lets the tests collect. test_workspace.py imports _UnixServer at module scope, which raised before this change and would have kept raising after it, so that module's own skipif never applied. The import now sits in the one test that uses it, and the whole suite collects on Windows: 1115 collected, 17 deselected, no collection errors. On main pytest fails while loading hud/conftest.py.

Left alone: hud/integrations/harbor/env.py imports grp and pwd at module scope. Nothing in the package imports that module, so it is off the import hud path and out of scope here.

Tests

hud/environment/tests/test_platform.py imports the package in a fresh interpreter that reports itself as Windows and has the unix pieces taken away. Before the fix it fails on each of the two separately: AttributeError for the server, and ModuleNotFoundError for pty once the server is guarded.

It imports the package once as the real platform first, because the standard library settles its own platform on first import (asyncio picks windows_events, shutil reaches for _winapi) and will not be told otherwise afterwards. Only the package's own modules are then dropped and imported again as Windows.

Validation

  • uv run pytest -q
  • uv run ruff format . --check and uv run ruff check .
  • uv run --extra dev --extra train --extra modal --extra daytona ty check --error-on-warning
  • Windows 11, CPython 3.12, the package installed from this branch: import hud and hud --version both work, and both fail on main.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8e7c7af. Configure here.

Comment thread hud/environment/egress.py
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.

1 participant