Skip to content

feat(cli): add update command to auto-upgrade based on package manager - #21426

Closed
roy-abir05 wants to merge 3 commits into
google-gemini:mainfrom
roy-abir05:feat/add-update-command
Closed

roy-abir05 wants to merge 3 commits into
google-gemini:mainfrom
roy-abir05:feat/add-update-command

Conversation

@roy-abir05

Copy link
Copy Markdown

Summary

Introduces a new gemini update subcommand that automatically detects the CLI's installation package manager (npm, brew, yarn, bun, pnpm) and executes the corresponding upgrade command. This reduces friction for users who frequently switch between package managers and eliminates the need to remember their original installation method.

Details

  • Wires updateCommand into the main Yargs router (config.ts).

  • Uses the existing getInstallationInfo utility to find the package manager, safely aborts for local/npx environments, and runs execSync with stdio: 'inherit'

  • Bypasses the interactive UI (argv['isCommand'] = true) and pipes logs through coreEvents.emitFeedback

  • Testing: Adds update.test.ts to mock child_process and verify execution paths

Related Issues

Fixes #21400

How to Validate

  • Run npm run build:all and link the binary locally.
  • Run gemini update
  • Observe the correct package manager detection (e.g., "Detected global installation via: npm...").
  • Verify the native upgrade command executes and completes successfully.
  • Run the test suite.
  • Verify edge case: run from a local git clone and ensure it gracefully prints "Running from a local git clone. Please update with 'git pull'." and exits with code 1.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@roy-abir05
roy-abir05 requested a review from a team as a code owner March 6, 2026 17:53
@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 enhances the Gemini CLI by adding a new update command. This command streamlines the upgrade process for users by automatically identifying how the CLI was installed and then running the appropriate package manager command to update it to the latest version. This change aims to reduce user friction and improve the overall maintainability of the CLI for end-users.

Highlights

  • New update subcommand: Introduced a new gemini update CLI command to simplify upgrading the Gemini CLI.
  • Automatic Package Manager Detection: The command automatically detects the CLI's installation package manager (e.g., npm, brew) and executes the correct upgrade command.
  • Graceful Handling of Installation Types: It safely aborts for local/npx environments, guiding users to update via git pull if installed from a local clone, and handles permission errors (EACCES) with specific guidance.
  • Integration and Testing: The updateCommand is wired into the main Yargs router, and comprehensive unit tests have been added to verify execution paths and error handling.
Changelog
  • packages/cli/src/commands/update.test.ts
    • Added unit tests for the new update command, covering global installation detection, npm updates, and error handling.
  • packages/cli/src/commands/update.ts
    • Implemented the core logic for the update command, which detects the installation method and executes the appropriate upgrade command.
  • packages/cli/src/config/config.ts
    • Imported the updateCommand and registered it with the Yargs CLI configuration.
Activity
  • The author has added new tests for the update command.
  • The author has validated the changes on Linux via npm run.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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. ↩

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

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.

Code Review

This pull request introduces a helpful gemini update command. The implementation is solid, but I've found a high-severity security issue in the error handling for permissions. The current implementation suggests an insecure practice to the user. My review includes a code suggestion to correct this by providing safer, more specific instructions and refactoring the code slightly for better error reporting.

Comment thread packages/cli/src/commands/update.ts Outdated
@gemini-cli gemini-cli Bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Mar 6, 2026
@roy-abir05

Copy link
Copy Markdown
Author

/gemini review

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

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.

Code Review

This pull request introduces a gemini update command, which is a useful addition for improving the user experience of keeping the CLI up-to-date. The implementation is straightforward and includes good test coverage. The feedback regarding making the permission error message platform-aware, as the current suggestion to use sudo is not applicable on Windows, has been retained.

Comment thread packages/cli/src/commands/update.ts Outdated
@roy-abir05

Copy link
Copy Markdown
Author

/gemini review

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

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.

Code Review

This pull request introduces a gemini update command to automate the CLI upgrade process. The new command detects the installation package manager and runs the corresponding update command. The implementation includes logic to handle cases where an automatic update is not possible, such as local development clones. Error handling is included for scenarios like permission failures, providing users with suggested next steps. The changes are accompanied by unit tests that validate the new command's behavior under various conditions. The implementation appears robust, and no high or critical severity issues were found.

@gemini-cli gemini-cli Bot added the priority/p2 Important but can be addressed in a future release. label Mar 11, 2026
@gemini-cli

gemini-cli Bot commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383).

We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'.

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community!

@cocosheng-g

Copy link
Copy Markdown
Contributor

@roy-abir05, apologies for the bot closing this PR! We have reopened it. Please sync your branch to the latest main and we will have someone review it shortly.

@gemini-cli gemini-cli Bot added the help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! label Apr 9, 2026
@roy-abir05
roy-abir05 force-pushed the feat/add-update-command branch from 88c11c4 to 3140d48 Compare April 10, 2026 12:18
@roy-abir05

Copy link
Copy Markdown
Author

Thanks for reopening this @cocosheng-g!
I have synced the branch with the latest main and resolved the merge conflicts. It is ready for review.

@roy-abir05

Copy link
Copy Markdown
Author

Hi @cocosheng-g!
Just giving this a gentle ping. I noticed the CI and E2E workflows are currently paused and require a maintainer's approval to run. Let me know if you need anything else from my end.

@spencer426

Copy link
Copy Markdown
Contributor

Thank you for your interest in contributing to the project! We are closing this PR as the associated issue was closed.

@spencer426 spencer426 closed this May 7, 2026
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p2 Important but can be addressed in a future release. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an update command

4 participants