fix(agent-core): handle cross-device ripgrep install - #178
Closed
lurenjia534 wants to merge 1 commit into
Closed
Conversation
🦋 Changeset detectedLatest commit: 6f1769e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Author
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.
Related Issue
Resolve #111
Problem
When ripgrep is not available on
PATH, Kimi Code downloads and extracts a managedrgbinary before installing it into the user cache directory. On systems where the temporary directory and the Kimi Code cache directory are on different filesystems, the finalrename()from the extracted file under/tmpto<KIMI_CODE_HOME>/bin/rgfails withEXDEV.This makes the automatic ripgrep bootstrap fail even though the download, checksum verification, and extraction have already succeeded.
What changed
The install step now keeps the existing fast path and still tries to
rename()the extracted binary directly first.If that direct rename fails specifically with
EXDEV, it falls back to copying the extracted binary into a staging directory next to the final destination, applies executable permissions there, and then renames the staged file into place on the same filesystem.Other rename failures are still surfaced unchanged, so permission errors, missing files, and other unexpected install problems are not hidden by the fallback.
Tests were added for both the
EXDEVfallback path and the non-EXDEVerror path.Validation
EXDEVfailure locally on Arch Linux by clearingPATH, forcing the real CDN bootstrap path, and installing into a temporaryshareDiron a different device from/tmp. The pre-fix flow downloaded, verified, and extracted ripgrep successfully, then failed on the final cross-devicerename()./tmpand the targetshareDirstill on different devices;ensureRgPath()returnedshare-bin-downloadedand installedrgsuccessfully.pnpm exec vitest run test/tools/rg-locator.test.tspnpm run typecheckinpackages/agent-corepnpm exec oxlint --type-aware packages/agent-core/src/tools/support/rg-locator.ts packages/agent-core/test/tools/rg-locator.test.tsPATHcleared and/tmpon a different device from the targetshareDirChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.