Windows/non-Linux portability bug: hardcoded /tmp paths crash the server at import

Author: ideabibCreated Aug 10, 2026Updated Sep 9, 2026

Summary

hexstrike_server.py hardcodes Linux-style /tmp paths in several places. On Windows these resolve to \tmp\... at the drive root (which does not exist), so Path.mkdir() raises FileNotFoundError.

Fatal at import (blocks startup on Windows)

PythonEnvironmentManager.__init__(self, base_dir="/tmp/hexstrike_envs") (line 5708) is instantiated at module import time (env_manager = PythonEnvironmentManager(), line 5744), so the server crashes before it can bind a port:

File "hexstrike_server.py", line 5744, in <module>
    env_manager = PythonEnvironmentManager()
File "hexstrike_server.py", line 5710, in __init__
    self.base_dir.mkdir(exist_ok=True)
FileNotFoundError: [WinError 3] The system cannot find the path specified: '\\tmp\\hexstrike_envs'

Also fails at runtime on Windows

  • FileOperationsManager default base_dir="/tmp/hexstrike_files" (line 8931) — fails when file operations are used.
  • Screenshot output f"/tmp/hexstrike_screenshot_{int(time.time())}.png" (lines 13687 and 14189) — fails when screenshots are taken.

Root cause

Unix /tmp is assumed. The two manager classes default to a Linux-only location with no Windows-aware fallback, and mkdir(..., exist_ok=True) will not create a missing parent root.

Suggested fix

Default to the OS temp dir (tempfile.gettempdir() works on Linux, macOS, and Windows) and create parent directories:

python
import tempfile

def __init__(self, base_dir=None):
    if base_dir is None:
        base_dir = str(Path(tempfile.gettempdir()) / "hexstrike_envs")
    self.base_dir = Path(base_dir)
    self.base_dir.mkdir(parents=True, exist_ok=True)

Apply the same pattern to FileOperationsManager, and resolve the screenshot output paths through tempfile.gettempdir() as well.

Related Windows note (possible separate issue)

On Windows, the server logs emoji (e.g. ) to stdout/stderr; when Python's stdio is a UTF-8-incapable pipe (default cp1252), logging raises UnicodeEncodeError and the process can die. Launching with PYTHONUTF8=1 (or PYTHONIOENCODING=utf-8) avoids it — worth noting in startup docs.

Environment

  • OS: Windows (affects any host without /tmp)
  • Python: 3.13
  • HexStrike AI: v6.0.0