Skip to content

fix(file-tools): normalize MSYS paths in _resolve_path_for_task on Windows (#44726) - #44765

Closed
HrushiYadav wants to merge 1 commit into
NousResearch:mainfrom
HrushiYadav:fix/file-tools-msys-path-normalization
Closed

fix(file-tools): normalize MSYS paths in _resolve_path_for_task on Windows (#44726)#44765
HrushiYadav wants to merge 1 commit into
NousResearch:mainfrom
HrushiYadav:fix/file-tools-msys-path-normalization

Conversation

@HrushiYadav

Copy link
Copy Markdown

Summary

On Windows + Git Bash/MSYS2, file tools silently write to wrong paths when the LLM passes MSYS-style paths (/d/Project/file.sh). Python's pathlib.Path treats /d/Project as "root \ on the current drive", resolving it to D:\d\Project instead of D:\Project.

The normalization already exists in the codebase (_msys_to_windows_path in tools/environments/local.py) and is used by the terminal tool, but was missing from file_tools._resolve_path_for_task.

Changes

  • tools/file_tools.py: import and call _msys_to_windows_path at the top of _resolve_path_for_task before Path() construction
  • tests/tools/test_file_tools_msys_path.py: 4 tests covering MSYS drive paths on Windows, native Windows paths passthrough, and non-Windows no-op

Test plan

  • New tests pass (pytest tests/tools/test_file_tools_msys_path.py)
  • Existing MSYS path tests still pass (pytest tests/tools/test_local_env_windows_msys.py)
  • Manual: on Windows + Git Bash, verify write_file with /d/Project/file resolves to D:\Project\file

Fixes #44726

…ndows

- call _msys_to_windows_path before Path construction so /d/Project
  resolves to D:\Project instead of D:\d\Project
- reuses existing normalization from tools/environments/local.py
@alt-glitch alt-glitch added type/bug Something isn't working tool/file File tools (read, write, patch, search) P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #44735 — same MSYS path normalization in file_tools._resolve_path_for_task for #44726. #44735 is the earlier open PR.

@HrushiYadav

Copy link
Copy Markdown
Author

Closing as duplicate of #44735.

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 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.

[Windows] write_file/patch silently write to wrong path when model uses MSYS-style paths (/d/Project → D:\d\Project)

2 participants