fix(ripgrep): handle broken symlinks gracefully in files() stream#24973
Open
aaronkyriesenbach wants to merge 1 commit into
Open
fix(ripgrep): handle broken symlinks gracefully in files() stream#24973aaronkyriesenbach wants to merge 1 commit into
aaronkyriesenbach wants to merge 1 commit into
Conversation
Ripgrep exits with code 2 when it encounters soft errors like broken symlinks or permission-denied paths, even though valid results are still written to stdout. The search() function already handled this, but files() treated exit code 2 as fatal — discarding all results. Add --no-messages to suppress stderr warnings in filesArgs() (matching searchArgs) and treat exit code 2 as non-fatal in the files() stream. This fixes the glob tool silently returning zero results when any broken symlink exists in the search tree.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #24972
Type of change
What does this PR do?
The glob tool silently returns zero results when any broken symlink or permission-denied path exists in the search tree. This happens because
Ripgrep.files()treats ripgrep exit code 2 as fatal — it discards all valid stdout output and fails the stream.The
search()function (used by the grep tool) already handles this correctly: it passes--no-messagesto suppress stderr warnings and treats exit code 2 as non-fatal.files()was missed.This PR brings
files()in line withsearch():--no-messagestofilesArgs()so stderr warnings about broken symlinks don't pollute output.files()stream so valid results already emitted to stdout are kept instead of discarded.How did you verify your code works?
files returns valid results despite broken symlinks) that creates a directory with a real file and a broken symlink, callsrg.files()withfollow: true, and asserts the real file is returned.bun turbo typecheck).rg --files --followreturns the target file on stdout but exits with code 2, which the unpatchedfiles()would treat as fatal.Screenshots / recordings
N/A — not a UI change.
Checklist