hermes - 💡(How to fix) Fix Windows: `os.path.relpath()` ValueError crash in `@` file autocomplete (cross-mount paths)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Unhandled exception in event loop:
  File "...\prompt_toolkit\buffer.py", line 1740, in async_completer
  File "...\prompt_toolkit\completion\base.py", line 310, in get_completions_async
  File "...\prompt_toolkit\completion\base.py", line 186, in get_completions_async
  File "...\hermes_cli\commands.py", line 1588, in get_completions
  File "...\hermes_cli\commands.py", line 1360, in _context_completions
  File "...\hermes_cli\commands.py", line 1450, in _fuzzy_file_completions
  File "...\hermes_cli\commands.py", line 1392, in _get_project_files
    rel = os.path.relpath(p, cwd) if os.path.isabs(p) else p
ValueError: '<device path>' is on mount '<NUL>', start on mount 'D:'

Root Cause

In hermes_cli/commands.py::_get_project_files(), when rg/fd returns an absolute path on a different Windows mount point (e.g., \\.\nul NUL device, or any path on a drive different from cwd), os.path.relpath(p, cwd) raises ValueError because the two paths share no common prefix on Windows. Since os.path.isabs(p) returns True for device paths like \\.\nul, the code unconditionally calls os.path.relpath() without catching the cross-mount ValueError.

Fix Action

Fix

Wrap os.path.relpath() in a try/except ValueError and skip the path:

if os.path.isabs(p):
    try:
        rel = os.path.relpath(p, cwd)
    except ValueError:
        # Windows: skip paths on different mount point (e.g. \\.\nul device)
        continue
else:
    rel = p
files.append(rel)

Code Example

Unhandled exception in event loop:
  File "...\prompt_toolkit\buffer.py", line 1740, in async_completer
  File "...\prompt_toolkit\completion\base.py", line 310, in get_completions_async
  File "...\prompt_toolkit\completion\base.py", line 186, in get_completions_async
  File "...\hermes_cli\commands.py", line 1588, in get_completions
  File "...\hermes_cli\commands.py", line 1360, in _context_completions
  File "...\hermes_cli\commands.py", line 1450, in _fuzzy_file_completions
  File "...\hermes_cli\commands.py", line 1392, in _get_project_files
    rel = os.path.relpath(p, cwd) if os.path.isabs(p) else p
ValueError: '<device path>' is on mount '<NUL>', start on mount 'D:'

---

if os.path.isabs(p):
    try:
        rel = os.path.relpath(p, cwd)
    except ValueError:
        # Windows: skip paths on different mount point (e.g. \\.\nul device)
        continue
else:
    rel = p
files.append(rel)
RAW_BUFFERClick to expand / collapse

Bug: os.path.relpath() crash on Windows when filesystem scan encounters cross-mount paths

Environment

  • OS: Windows
  • Hermes Agent: latest
  • Trigger: typing @ in TUI to invoke file autocomplete

Stack Trace

Unhandled exception in event loop:
  File "...\prompt_toolkit\buffer.py", line 1740, in async_completer
  File "...\prompt_toolkit\completion\base.py", line 310, in get_completions_async
  File "...\prompt_toolkit\completion\base.py", line 186, in get_completions_async
  File "...\hermes_cli\commands.py", line 1588, in get_completions
  File "...\hermes_cli\commands.py", line 1360, in _context_completions
  File "...\hermes_cli\commands.py", line 1450, in _fuzzy_file_completions
  File "...\hermes_cli\commands.py", line 1392, in _get_project_files
    rel = os.path.relpath(p, cwd) if os.path.isabs(p) else p
ValueError: '<device path>' is on mount '<NUL>', start on mount 'D:'

Root Cause

In hermes_cli/commands.py::_get_project_files(), when rg/fd returns an absolute path on a different Windows mount point (e.g., \\.\nul NUL device, or any path on a drive different from cwd), os.path.relpath(p, cwd) raises ValueError because the two paths share no common prefix on Windows. Since os.path.isabs(p) returns True for device paths like \\.\nul, the code unconditionally calls os.path.relpath() without catching the cross-mount ValueError.

Fix

Wrap os.path.relpath() in a try/except ValueError and skip the path:

if os.path.isabs(p):
    try:
        rel = os.path.relpath(p, cwd)
    except ValueError:
        # Windows: skip paths on different mount point (e.g. \\.\nul device)
        continue
else:
    rel = p
files.append(rel)

Impact

All Windows users can hit this crash when using @ file autocomplete in the TUI. It's an unhandled exception that kills the event loop.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING