Skip to content

fix: strip anchored glob patterns on Windows to avoid NotImplementedError - #5682

Open
icn5381 wants to merge 1 commit into
Aider-AI:mainfrom
icn5381:fix/5679-windows-glob-anchored-pattern
Open

fix: strip anchored glob patterns on Windows to avoid NotImplementedError#5682
icn5381 wants to merge 1 commit into
Aider-AI:mainfrom
icn5381:fix/5679-windows-glob-anchored-pattern

Conversation

@icn5381

@icn5381 icn5381 commented Sep 5, 2026

Copy link
Copy Markdown

Issue

Fixes #5679
Fixes #5675

On Windows, a pattern starting with / is not absolute per os.path.isabs() (no drive letter), but pathlib.Path.glob() treats it as an "anchored" pattern and raises NotImplementedError: Non-relative patterns are unsupported. This crashes /add and /read-only when the user passes a forward-slash path like /add /some/file.py.

Fix

  • Add _safe_glob_pattern() helper: on Windows (os.name == "nt"), strips the leading / from a pattern so Path.glob() treats it as relative to the glob root (which is what the user intended). No-op on POSIX.
  • Apply it at both Path.glob() call sites in commands.py (glob_filtered_to_repo ~line 774, read-only file collection ~line 1361).
  • Add NotImplementedError to the existing exception handler in glob_filtered_to_repo as a fallback for any other anchored-pattern shapes.

Testing

4 new unit tests in TestSafeGlobPattern cover:

  • POSIX passthrough (unchanged)
  • Windows strips /foo/barfoo/bar
  • Windows preserves non-anchored patterns (*.py, src/file.py)
  • Windows preserves drive paths (C:/drive/file.py)

Note: the full test suite could not be run locally because Python 3.14 removed audioop, which pydub (an aider dependency) requires. The helper function logic was verified independently with mocked os.name on both platforms.

…rror

On Windows, a pattern starting with / is not absolute per
os.path.isabs() (no drive letter), but pathlib.Path.glob() treats it
as an anchored pattern and raises NotImplementedError. This crashed
/add and /read-only when the user passed a forward-slash path on
Windows.

Add _safe_glob_pattern() to strip the leading slash on Windows (it
is a no-op on POSIX), apply it at both Path.glob() call sites in
commands.py, and add NotImplementedError to the exception handler in
glob_filtered_to_repo as a belt-and-braces fallback.

Fixes Aider-AI#5679
Fixes Aider-AI#5675
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

Uncaught NotImplementedError in pathlib.py line 1032 Uncaught NotImplementedError in _local.py line 589

2 participants