Skip to content

fix(tools): pass native Windows paths to ripgrep under MSYS_NO_PATHCONV - #77443

Closed
sotwind wants to merge 1 commit into
NousResearch:mainfrom
sotwind:fix/windows-native-rg-path
Closed

fix(tools): pass native Windows paths to ripgrep under MSYS_NO_PATHCONV#77443
sotwind wants to merge 1 commit into
NousResearch:mainfrom
sotwind:fix/windows-native-rg-path

Conversation

@sotwind

@sotwind sotwind commented Aug 3, 2026

Copy link
Copy Markdown

Problem

On Windows, the search_files tool fails for every explicit absolute path when the installed ripgrep is a native Windows build (e.g. the WinGet MSVC package):

rg: /e/HermesWork/proj: IO error for operation on /e/HermesWork/proj: The system cannot find the path specified. (os error 3)

Root cause chain:

  1. ShellFileOperations._escape_shell_arg rewrites drive paths (E:\...) to the Git Bash /e/... form — required for MSYS tools (grep, find, test, bash builtins).
  2. Hermes launches bash with MSYS_NO_PATHCONV=1 / MSYS2_ARG_CONV_EXCL=*, so argv reaches native binaries verbatim (no /e/...E:\... translation back).
  3. Native rg.exe cannot resolve /e/... and errors out.

Only the default relative root (.) worked, because no drive-path rewrite happens there.

Fix

Add ShellFileOperations._escape_native_tool_arg(), which converts the path to the native E:/... form on Windows (via _msys_to_windows_path; idempotent, no-op off Windows) and use it for the path argument at the three ripgrep invocation sites:

  • _search_with_rg (content search)
  • _search_files_rg sorted command
  • _search_files_rg plain fallback

MSYS-built rg also accepts native paths, so this is safe for either flavor. grep/find/test call sites intentionally keep the MSYS form.

Testing

  • New tests/tools/test_file_ops_native_tool_arg.py (9 tests): path-form conversion matrix on/off Windows, plus command-construction tests asserting rg receives the native form.
  • Windows 11 + Git Bash + ripgrep 15.1.0 (WinGet MSVC), end-to-end via search_tool: content search on a single file and a directory, --files glob search, glob+path combo, no-match case, and context mode all succeed with absolute native paths.
  • Existing suites test_file_operations.py + test_search_auto_multiline.py on that machine: 41 passed / 10 failed with this change vs 38 passed / 13 failed without it — the change fixes 3 pre-existing failures and introduces none (the remaining failures are pre-existing Windows-environment issues: POSIX umask, symlink, and rg-multiline cases, all failing on unmodified main too).

_escape_shell_arg rewrites drive paths to the Git Bash /c/... form,
which MSYS tools (grep/find/test) require. Native binaries are
different: Hermes runs bash with MSYS_NO_PATHCONV=1 and
MSYS2_ARG_CONV_EXCL=*, so argv reaches them verbatim, and a native
ripgrep build (e.g. the WinGet MSVC package) cannot resolve /c/... --
every explicit-path search failed with 'IO error ... The system cannot
find the path specified (os error 3)'. Only the default relative root
('.') worked.

Add ShellFileOperations._escape_native_tool_arg() which converts the
path to the native C:/... form on Windows (via _msys_to_windows_path,
idempotent, no-op off Windows) and use it for the path argument at the
three ripgrep invocation sites (_search_with_rg, _search_files_rg
sorted + plain fallback). MSYS-built rg also accepts native paths, and
grep/find/test call sites intentionally keep the MSYS form.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/file File tools (read, write, patch, search) backend/local Local shell execution platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows duplicate This issue or pull request already exists labels Aug 3, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #67914, which already covers the native-ripgrep path conversion and adds backend gating to protect remote paths.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as implemented on main: #84378 (merged) covers this fix — a shared native-path escaper (_escape_native_tool_arg) applied to all six rg call sites, the zero-match probes, and the shell linter interpolation, with Windows regression tests. Thank you for diagnosing this — your PR correctly identified the same root cause (native binaries + MSYS_NO_PATHCONV means /c/... is never translated back), and the merged fix lands the same approach across the full call-site set. Sorry we couldn't land this one directly.

@teknium1 teknium1 closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/local Local shell execution duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows tool/file File tools (read, write, patch, search) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants