Skip to content

fix(files): preserve native Windows paths for ripgrep - #72922

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

fix(files): preserve native Windows paths for ripgrep#72922
lifeFedorovAlexey wants to merge 1 commit into
NousResearch:mainfrom
lifeFedorovAlexey:fix/windows-rg-absolute-path

Conversation

@lifeFedorovAlexey

@lifeFedorovAlexey lifeFedorovAlexey commented Jul 27, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes search_files with absolute Windows paths when Hermes runs under Git Bash but invokes native rg.exe.

Hermes intentionally disables MSYS argv conversion. The existing generic shell escaping then rewrites C:/Users/... to /c/Users/..., which reaches native ripgrep verbatim and fails with IO error 3. This PR preserves drive-letter paths only at the native-ripgrep boundary while leaving MSYS paths intact for shell builtins and fallback tools.

Related Issue

Fixes #63177
Fixes #67629

Related: #72047

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • tools/file_operations.py: add native-CLI path escaping and use it for all three ripgrep path arguments.
  • tests/tools/test_file_operations.py: cover native C:\\... and MSYS /c/... inputs while preserving existing shell escaping.

How to Test

  1. On native Windows with Git Bash and native rg.exe, call search_files with an absolute C:/Users/... path.
  2. Confirm ripgrep receives C:/..., not /c/..., and returns matching files/content.
  3. Run:
    env -u VIRTUAL_ENV uv run --no-project --python 3.12 --with pytest --with pytest-xdist python -m pytest tests/tools/test_file_operations.py -q -n 0 -k 'native_windows_cli_keeps_drive_paths_for_rg or escape_shell_arg_rewrites_windows_drive_paths_to_msys'

Result: 2 passed.

Checklist

Code

  • I've read the Contributing Guide.
  • My commit messages follow Conventional Commits.
  • I searched open and closed PRs and issues for duplicates.
  • My PR contains only changes related to this fix.
  • I've run pytest tests/ -q and all tests pass (targeted affected tests were run; full upstream CI remains authoritative).
  • I've added tests for my changes.
  • I've tested on Windows 10 with native ripgrep and Git Bash.

Documentation & Housekeeping

  • Documentation update — N/A; behavior is internal and regression-covered.
  • cli-config.yaml.example update — N/A; no config keys changed.
  • CONTRIBUTING.md / AGENTS.md update — N/A; no architecture or workflow changed.
  • Cross-platform impact considered: non-Windows behavior delegates to the existing escaping path unchanged.
  • Tool descriptions/schemas update — N/A; public tool contract is unchanged.

Screenshots / Logs

Before:

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

After: the same absolute-path search_files request returns matches in the running Windows Hermes environment.

@alt-glitch alt-glitch added type/bug Something isn't working tool/file File tools (read, write, patch, search) platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows duplicate This issue or pull request already exists labels Jul 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #63458: both patches repair the same three native ripgrep path arguments in tools/file_operations.py and add equivalent Windows-path regression coverage. #67940 remains related as a broader policy/documentation variant.

@lifeFedorovAlexey

Copy link
Copy Markdown
Author

Confirmed — #63458 addresses the same three native ripgrep path arguments and already carries stronger call-site regression coverage. I am closing this PR as a duplicate rather than competing with the existing contribution. I also verified the approach against a real native-Windows Hermes environment: an absolute C:/Users/... search_files request succeeds once rg.exe receives the drive-qualified path.

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

Labels

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

2 participants