Skip to content

fix: guard Unix-only grp import behind sys.platform check for Windows compatibility#7

Merged
tom-sapletta-com merged 3 commits into
mainfrom
copilot/fix-windows-cli-startup-issue
Jul 16, 2026
Merged

fix: guard Unix-only grp import behind sys.platform check for Windows compatibility#7
tom-sapletta-com merged 3 commits into
mainfrom
copilot/fix-windows-cli-startup-issue

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

init_host_environment.py unconditionally imports Python's built-in grp module, which is Unix-only. On Windows this raises ModuleNotFoundError at import time, blocking the entire CLI before argument parsing — koru --help, --version, and --doctor all fail immediately.

Changes

  • src/koru/init_host_environment.py — replace top-level import grp with a platform-conditional import:

    if sys.platform != "win32":
        import grp as _grp
    else:
        _grp = None  # type: ignore[assignment]

    Update _uinput_snapshot() to guard the grp.getgrgid() call with _grp is not None, falling back to the raw numeric GID string. On Windows /dev/uinput is absent anyway so the guard is never reached in practice.

  • tests/test_init.py — two new tests:

    • test_grp_sentinel_matches_platform: verifies _grp is None on Windows and the real grp module elsewhere.
    • test_uinput_snapshot_absent_device: verifies _uinput_snapshot() never raises and always returns a dict containing "present", regardless of platform.

Copilot AI changed the title [WIP] Fix Windows CLI startup failure caused by Unix-only grp import fix: guard Unix-only grp import behind sys.platform check for Windows compatibility Jul 16, 2026
Copilot AI requested a review from tom-sapletta-com July 16, 2026 09:01

@MatthiasLew MatthiasLew 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.

Verified on native Windows 11 with Python 3.13.14 and PowerShell 5.1. The original blocking grp import issue is resolved: koru --help, koru --version, and koru --doctor --project . now start successfully. All 29 tests in tests/test_init.py pass. The remaining full-suite Windows failures are unrelated platform-specific issues and should be handled separately.

@tom-sapletta-com
tom-sapletta-com marked this pull request as ready for review July 16, 2026 10:06
@tom-sapletta-com
tom-sapletta-com merged commit 61b5e3e into main Jul 16, 2026
1 check failed
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.

Windows: CLI fails on startup because init_host_environment.py imports Unix-only grp module

3 participants