fix(dev-mcp): resolve ripgrep on Windows PATH - #3731
Open
sumit-m wants to merge 1 commit into
Open
Conversation
clean_path and which_rg split PATH on ':', so on Windows every entry's drive colon tore it apart and no directory survived; the lookup also omitted the .exe suffix. Search silently fell through to the built-in walker every time. Use env::split_paths/join_paths and a target-specific binary name. Signed-off-by: sumit-m <33051892+sumit-m@users.noreply.github.com>
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.
Problem
rg.rssplits and rejoinsPATHon':'. Windows separates entries with;, and every entry carries a drive colon, soC:\tools\bin;C:\Users\x\binshredded intoC,\tools\bin;C,\Users\x\bin— no usable directory survived. The lookup also joined the bare namerg, omitting the.exesuffix, sois_file()would have failed even on an entry that did survive.Net effect on Windows:
try_system_rgcan never succeed, and every search silently falls through to the built-in walker. Degraded rather than broken, which is presumably why it went unnoticed.Change
clean_pathandwhich_rguseenv::split_paths/env::join_paths, which use the platform separator.RG_EXEconst suppliesrg.exeon Windows,rgelsewhere.clean_pathnow works inOsStringrather thanString, avoiding a lossy round-trip.join_pathsfailure yields an emptyPATHrather than the original. That is the safe direction: returning the original would put this shim's own directory back in play and risk recursing into ourselves.Tests
Four new tests:
which_rgfinds a binary past an earlierPATHentry (the regression guard — both entries are absolute, so on Windows they carry drive colons), returnsNonewhen no entry holds the binary, ignores empty entries, andclean_path's filter drops the directory holding the shim.cargo clippy -p buzz-dev-mcp --all-targetsclean. Noteshell::testsis flaky on Windows under the parallel suite both before and after this change —Shim::installcallsenv::remove_varand rebuildsPATHfrom process env, which parallel test threads race. Untouched here.