Skip to content

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

Closed

Description

@ham-zax

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/

Activity

  1. github-actions commented on Dec 22, 2025

    @github-actions
    Contributor

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

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

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions