Skip to content

rtfm CLI is completely broken on native Windows: unconditional 'import fcntl' in core.supervisor #8

Description

@AVeryTastyRaspberry

Summary

rtfm-ai 0.35.7 (latest on PyPI) is entirely unusable via the rtfm CLI on native Windows Python (tested: Python 3.12.10, Windows 11, pip 26.2.1). Every command crashes at import time before argument parsing even happens.

Root cause

rtfm/core/supervisor.py does an unconditional, top-level import fcntl:

from __future__ import annotations

import fcntl
import json
import os
import signal
import socket
...

fcntl is POSIX-only and does not exist on Windows. There is no msvcrt-based fallback anywhere in the package — I checked every file under rtfm/core/ and none of them branch on platform for locking.

Since the 0.16.x rearchitecture (per the module docstring: "every mutating command is a thin producer: it enqueues P0 jobs, ensures the worker daemon is running, and watches queue stats"), every mutating CLI commandinit, sync, scan, and therefore all indexing — routes through rtfm/cli_worker.py, which imports rtfm.core.supervisor at module level. rtfm/cli.py's main() imports cli_worker unconditionally too, so the crash happens for any CLI invocation, not just worker/daemon subcommands.

Repro

> pip install rtfm-ai
> rtfm --version
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "...\Scripts\rtfm.exe\__main__.py", line 5, in <module>
  File "...\site-packages\rtfm\cli.py", line 2738, in main
    from rtfm.cli_worker import cmd_worker, cmd_worker_daemon, cmd_queue
  File "...\site-packages\rtfm\cli_worker.py", line 31, in <module>
    from rtfm.core.supervisor import (
  File "...\site-packages\rtfm\core\supervisor.py", line 33, in <module>
    import fcntl
ModuleNotFoundError: No module named 'fcntl'

This reproduces even for --version/--help, since the crash is at import time before argparse runs.

What still works

rtfm-serve (the MCP stdio server, rtfm/_mcp/server.py) is a separate, pure-stdlib entry point that does not import cli_worker/supervisor, and it runs cleanly on Windows (rtfm-serve --help exits 0). So the MCP server itself is fine — the problem is entirely confined to the worker/supervisor code path that the CLI depends on for indexing.

Impact

There is currently no way to run rtfm init/sync/scan — i.e. to populate .rtfm/library.db at all — on native Windows Python. The only workaround is running the CLI inside WSL/Linux against a Windows-mounted path, which works (fcntl exists there) but isn't a fix, and isn't discoverable from the README's "runs on ... Windows" claim.

Suggested fix

Guard the lock acquisition in supervisor.py (and anywhere else fcntl is used) behind a platform check, falling back to msvcrt.locking() on Windows, or to a portable cross-platform lock library. Happy to help test a patch if useful — flagging as filed by an AI coding agent (Claude Code) on behalf of a user evaluating rtfm for two Windows-based repos.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions