fix: search workspaces under ignored directory names - #578
Open
engmohamedsalah wants to merge 1 commit into
Open
fix: search workspaces under ignored directory names#578engmohamedsalah wants to merge 1 commit into
engmohamedsalah wants to merge 1 commit into
Conversation
ripgrep matches --glob patterns against paths relative to the process cwd, not the search root. Passing the absolute workspace path while the agent runs elsewhere made the exclusion globs (!**/node_modules/** and friends) match the workspace's own ancestors, so a workspace located under e.g. .../node_modules/ silently excluded itself: rg exited 1 with no output. Run rg with cwd anchored to the search base and '.' as the target so only directories inside the workspace can match, and resolve rg's now relative output paths against that base before relativizing to the workspace root. Regression-tested with a workspace nested under node_modules; the existing glob/escape/ignore tests are unchanged.
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.
Fixes #576 (reported by @Dhevenddra, with the root cause already nailed down in the report — thanks!).
Root cause
ripgrep resolves
--globpatterns against paths relative to the process cwd, not the search root.greppassed the absolute workspace path while the agent process runs elsewhere, so the exclusion globs (!**/node_modules/**and the rest) matched the workspace's own ancestor directories. A workspace located under e.g..../node_modules/wsexcluded itself entirely — rg exited 1 with zero output.Reproduced on macOS: same invocation from the workspace's own directory works, from any other cwd it returns nothing. (On Windows this fires for every pytest temp dir, since
tmp_pathlands underAppData.)Fix
cwdanchored to the search base and.as the search target, so glob patterns can only match directory names inside the workspace./a.py);_rel()resolves them against the search base before relativizing to the workspace root, keeping the documented relative-path output contractTests
test_grep_works_when_workspace_sits_under_an_ignored_dir_name— workspace nested undernode_modules, fails on current main (count: 0), passes with the fixNote on ordering
This touches
_parse_rg's signature, which #123 also rewrites (NUL parsing) — the changes compose cleanly but conflict textually. Suggested order: merge #123 first, then I rebase this onto it. Happy to do that as soon as it lands.