-
Notifications
You must be signed in to change notification settings - Fork 9.9k
fix(cli): handle global npm auto-update by uninstalling first #14618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(cli): handle global npm auto-update by uninstalling first #14618
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @stephen-taipei, 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 CLI's auto-update mechanism by addressing a common issue with global npm installations. Previously, direct updates could fail due to directory conflicts. The change introduces a robust pre-uninstall step for global npm packages, ensuring a clean and successful update process, thereby improving the overall reliability and user experience of the auto-updater. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 addresses an issue with global npm auto-updates by introducing an uninstall-before-install flow to prevent ENOTEMPTY errors. The changes correctly modify the update command for global npm installations, and the tests have been updated to reflect this new command flow. I have one suggestion to improve the maintainability of the implementation by avoiding a hardcoded package name.
| const updateCommand = | ||
| installationInfo.packageManager === PackageManager.NPM && | ||
| installationInfo.isGlobal | ||
| ? `npm uninstall -g @google/gemini-cli && ${resolvedUpdateCommand}` | ||
| : resolvedUpdateCommand; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package name @google/gemini-cli is hardcoded in the generated uninstall command. To improve maintainability and prevent potential issues if the package name changes in the future, it's better to use the dynamic package name available from the info.update.name property.
| const updateCommand = | |
| installationInfo.packageManager === PackageManager.NPM && | |
| installationInfo.isGlobal | |
| ? `npm uninstall -g @google/gemini-cli && ${resolvedUpdateCommand}` | |
| : resolvedUpdateCommand; | |
| const updateCommand = | |
| installationInfo.packageManager === PackageManager.NPM && | |
| installationInfo.isGlobal | |
| ? `npm uninstall -g ${info.update.name} && ${resolvedUpdateCommand}` | |
| : resolvedUpdateCommand; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. The update has been applied.
Please let me know if more adjustments are required.
3245f92 to
75cce0d
Compare
Summary
Details
npm uninstall -g @google/gemini-clibefore the resolved update commandnpm run buildto ensure packages compileRelated Issues
Fixes #4664
How to Validate
Pre-Merge Checklist