Skip to content

fix(cli): restore previous extension on failed update#26930

Open
Eswar809 wants to merge 2 commits into
google-gemini:mainfrom
Eswar809:fix/extension-update-rollback
Open

fix(cli): restore previous extension on failed update#26930
Eswar809 wants to merge 2 commits into
google-gemini:mainfrom
Eswar809:fix/extension-update-rollback

Conversation

@Eswar809
Copy link
Copy Markdown
Contributor

Summary

If loadExtension or any of the file operations after the destructive uninstall step (mkdir, copyExtension, metadata write, integrity check, load)
failed during an extension update, the user was left without a working extension. A pre-existing TODO at the loadExtension call site already
acknowledged this gap.

Snapshot the previous extension directory into a temp dir (via ExtensionStorage.createTmpDir()) before the destructive sequence. On any update failure,
rm -rf the partial new destination and copyExtension the snapshot back into the original location. The snapshot is unconditionally cleaned up in
finally on both success and failure paths.

The broader (uninstall → copy → metadata → integrity → load) window is covered, not just the load step the TODO pointed at — any of those steps failing
equally orphans the user.

Fixes #21671

Test plan

  • Full extension test suite — 96/96 pass (no regression in existing install/update/uninstall paths)
  • npm run preflight exit 0

If loadExtension or any of the file operations after the destructive
uninstall step (mkdir, copy, metadata write, integrity check, load) failed
during an extension update, the user was left without a working extension.
The existing code carried a TODO acknowledging this gap.

Snapshot the previous extension directory into a temp dir before the
uninstall+copy sequence, and on any update failure rm the partial new
destination and restore the previous version from the snapshot. The snapshot
is unconditionally cleaned up in finally on both success and failure paths.

Fixes google-gemini#21671
@Eswar809 Eswar809 requested a review from a team as a code owner May 12, 2026 18:00
@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 improves the reliability of the extension update process by introducing a rollback mechanism. By creating a temporary snapshot of the current extension before applying updates, the system can now gracefully recover if any part of the installation sequence fails, preventing users from being left with a non-functional extension.

Highlights

  • Robust Extension Updates: Implemented a snapshot mechanism to back up the existing extension directory before performing destructive update operations.
  • Automated Rollback: Added error handling to automatically restore the previous extension version if any step in the update process fails, ensuring the user is never left with a broken state.
  • Cleanup Logic: Introduced a finally block to ensure temporary backup directories are reliably removed regardless of whether the update succeeded or failed.
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 the 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 counterproductive. 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.

@gemini-cli gemini-cli Bot added priority/p1 Important and should be addressed in the near term. priority/p2 Important but can be addressed in a future release. area/extensions Issues related to Gemini CLI extensions capability labels May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/extensions Issues related to Gemini CLI extensions capability priority/p1 Important and should be addressed in the near term. priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): extension update leaves user without working extension if loadExtension fails

1 participant