Grep tool fails on Windows: CRLF line ending not stripped from ripgrep path #3747

Closed
opened 2026-02-16 17:41:19 -05:00 by yindo · 1 comment
Owner

Originally created by @ham-zax on GitHub (Dec 22, 2025).

Originally assigned to: @rekram1-node on GitHub.

Bug Description

The built-in grep tool fails on Windows because it doesn't strip the carriage return (\r) from the ripgrep path returned by where rg.

Environment

  • OS: Windows 10/11
  • ripgrep version: 14.1.0
  • ripgrep location: C:\ProgramData\chocolatey\bin\rg.exe (installed via Chocolatey)

Steps to Reproduce

  1. Have ripgrep installed on Windows (via Chocolatey, Scoop, or Winget)
  2. Use the grep tool in opencode

Expected Behavior

Grep tool finds and executes ripgrep successfully.

Actual Behavior

Error: Executable not found in $PATH: "C:\ProgramData\chocolatey\bin\rg.exe\r"

Note the \r at the end of the path.

Root Cause

The grep tool appears to run where rg to locate ripgrep on Windows. Windows returns paths with CRLF line endings (\r\n). The tool strips \n but leaves the \r, resulting in an invalid path.

Evidence:

> where rg
C:\ProgramData\chocolatey\bin\rg.exe\r\n
C:\Users\Hamza\AppData\Local\Microsoft\WinGet\Links\rg.exe\r\n

Suggested Fix

When parsing the output of where rg on Windows, strip both \r and \n:

// Instead of:
path = strings.TrimSuffix(path, "\n")

// Use:
path = strings.TrimSpace(path)
// or
path = strings.TrimRight(path, "\r\n")

Workaround

Use bash tool with rg command directly:

rg "pattern" --glob "*.py" src/
Originally created by @ham-zax on GitHub (Dec 22, 2025). Originally assigned to: @rekram1-node on GitHub. ## Bug Description The built-in `grep` tool fails on Windows because it doesn't strip the carriage return (`\r`) from the ripgrep path returned by `where rg`. ## Environment - **OS:** Windows 10/11 - **ripgrep version:** 14.1.0 - **ripgrep location:** `C:\ProgramData\chocolatey\bin\rg.exe` (installed via Chocolatey) ## Steps to Reproduce 1. Have ripgrep installed on Windows (via Chocolatey, Scoop, or Winget) 2. Use the `grep` tool in opencode ## Expected Behavior Grep tool finds and executes ripgrep successfully. ## Actual Behavior ``` Error: Executable not found in $PATH: "C:\ProgramData\chocolatey\bin\rg.exe\r" ``` Note the `\r` at the end of the path. ## Root Cause The grep tool appears to run `where rg` to locate ripgrep on Windows. Windows returns paths with CRLF line endings (`\r\n`). The tool strips `\n` but leaves the `\r`, resulting in an invalid path. **Evidence:** ``` > where rg C:\ProgramData\chocolatey\bin\rg.exe\r\n C:\Users\Hamza\AppData\Local\Microsoft\WinGet\Links\rg.exe\r\n ``` ## Suggested Fix When parsing the output of `where rg` on Windows, strip both `\r` and `\n`: ```go // Instead of: path = strings.TrimSuffix(path, "\n") // Use: path = strings.TrimSpace(path) // or path = strings.TrimRight(path, "\r\n") ``` ## Workaround Use `bash` tool with `rg` command directly: ```bash rg "pattern" --glob "*.py" src/ ```
yindo added the windows label 2026-02-16 17:41:19 -05:00
yindo closed this issue 2026-02-16 17:41:19 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 22, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #5727: OpenCode Desktop Windows ripgrep always fail - Reports ripgrep failing on Windows 10 when executing tasks
  • #3389: no such file or directory, uv_spawn 'C:\Users\user.local\share\opencode\bin\rg.exe' - Similar Windows path issue with ripgrep exe not being found despite file existing

All three issues involve Windows-specific ripgrep path resolution failures. Feel free to ignore if your specific case differs from these.

@github-actions[bot] commented on GitHub (Dec 22, 2025): This issue might be a duplicate of existing issues. Please check: - #5727: OpenCode Desktop Windows ripgrep always fail - Reports ripgrep failing on Windows 10 when executing tasks - #3389: no such file or directory, uv_spawn 'C:\Users\user\.local\share\opencode\bin\rg.exe' - Similar Windows path issue with ripgrep exe not being found despite file existing All three issues involve Windows-specific ripgrep path resolution failures. Feel free to ignore if your specific case differs from these.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3747