Skip to content

fix(core): implement system ripgrep fallback when bundled binary is missing#26387

Open
chaitanyabisht wants to merge 1 commit intogoogle-gemini:mainfrom
chaitanyabisht:fix-ripgrep-resolution-and-bundling
Open

fix(core): implement system ripgrep fallback when bundled binary is missing#26387
chaitanyabisht wants to merge 1 commit intogoogle-gemini:mainfrom
chaitanyabisht:fix-ripgrep-resolution-and-bundling

Conversation

@chaitanyabisht
Copy link
Copy Markdown

@chaitanyabisht chaitanyabisht commented May 2, 2026

Description

This PR implements a fallback mechanism to detect and use a system-installed ripgrep binary when the bundled vendor binaries are not available.

Context

Previous updates (PR #25841) successfully removed architecture-specific ripgrep binaries from NPM tarballs to significantly reduce package size. However, while this optimization was beneficial for package weight, it unintentionally left NPM users without a high-performance search path because the CLI lacked the logic to check the host system's PATH for an existing rg installation.

As a result, users with ripgrep already installed on their machines were still seeing "Ripgrep is not available" warnings and experiencing severe search performance degradation due to the mandatory fallback to the JavaScript-based GrepTool.

Changes

  • Updated getRipgrepPath in packages/core/src/tools/ripGrep.ts to check the system PATH using the isBinaryAvailable utility if bundled binaries are missing.

Testing

  • Local Verification: Verified the fix by running a locally bundled version of the CLI without internal vendor binaries.
  • Debug Logging: Confirmed via --debug logs that the CLI successfully identifies and executes the system rg binary.
  • Regression Testing: Verified that the "Ripgrep is not available. Falling back to GrepTool" warning is no longer triggered when a system rg is present.
  • Validation: Ran the full npm run preflight suite; all linting and unit tests passed successfully.

Fixes #26193

PR google-gemini#25841 removed ripgrep binaries from the NPM tarballs to save space, with the stated assumption that the CLI could fall back to a system-installed ripgrep. However, this fallback logic was never actually implemented, forcing all NPM users onto the slow JavaScript GrepTool. This commit implements the missing fallback logic in ripGrep.ts to check the system PATH.
@chaitanyabisht chaitanyabisht marked this pull request as ready for review May 2, 2026 20:13
@chaitanyabisht chaitanyabisht requested a review from a team as a code owner May 2, 2026 20:13
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where the removal of architecture-specific binaries from NPM tarballs left users without an efficient search mechanism. By adding logic to check the system's PATH for an existing ripgrep installation, the CLI now correctly identifies and uses local system binaries, restoring expected performance levels for users who have the tool installed independently.

Highlights

  • System Ripgrep Fallback: Implemented a fallback mechanism in the getRipgrepPath utility to detect and utilize a system-installed rg binary when bundled vendor binaries are missing.
  • Performance Restoration: Ensures that users with ripgrep installed on their host machine can leverage high-performance search capabilities, avoiding the performance degradation associated with the JavaScript-based GrepTool fallback.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a fallback mechanism to locate the ripgrep binary by checking the system PATH using a new isBinaryAvailable utility. The feedback recommends removing these explicit pre-checks and the fallback logic, suggesting instead to rely on the environment's PATH and the built-in error handling of spawn or spawnSync for missing binaries.

import { RIP_GREP_DEFINITION } from './definitions/coreTools.js';
import { resolveToolDeclaration } from './definitions/resolver.js';
import { type GrepMatch, formatGrepResults } from './grep-utils.js';
import { isBinaryAvailable } from '../utils/binaryCheck.js';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Instead of introducing a new isBinaryAvailable utility or using resolveExecutable, remove the pre-check entirely. Rely on the built-in error handling of spawn and spawnSync for command not found errors, as explicit pre-checks are discouraged in this repository.

References
  1. Rely on the built-in error handling of spawn and spawnSync for 'command not found' errors instead of adding an explicit commandExists pre-check.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this specific case, the pre check is needed because it must resolve the correct path (bundled vs system) during the init

Comment on lines +65 to +68
// 3. Fallback to system PATH
if (isBinaryAvailable('rg')) {
return 'rg';
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Avoid adding an explicit fallback check for the system ripgrep binary. It is preferred to rely on the environment's PATH and the built-in error handling of spawn/spawnSync to handle missing binaries rather than performing a pre-check.

References
  1. Rely on the built-in error handling of spawn and spawnSync for 'command not found' errors instead of adding an explicit commandExists pre-check.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Ripgrep is not available. Falling back to GrepTool." message shown (only) in non-interactive mode

1 participant