fix(cli): use os.homedir() for home directory warning check#26410
Draft
HaleTom wants to merge 1 commit intogoogle-gemini:mainfrom
Draft
fix(cli): use os.homedir() for home directory warning check#26410HaleTom wants to merge 1 commit intogoogle-gemini:mainfrom
HaleTom wants to merge 1 commit intogoogle-gemini:mainfrom
Conversation
The home directory warning incorrectly used the core homedir() helper which respects the GEMINI_CLI_HOME environment variable. When GEMINI_CLI_HOME is set to a non-home directory, the warning could fire in subdirectories or miss the actual home directory entirely. Switch to Node's native os.homedir() so the check always compares against the real OS home directory. Add test coverage for subdirectories, symlinked home directories, and GEMINI_CLI_HOME override scenarios. Fixes google-gemini#22309
Contributor
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
46db34e to
28580cf
Compare
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.
Summary
The "running in home directory" warning was triggering incorrectly in subdirectories of home. The root cause: the warning check used the core
homedir()helper, which respects theGEMINI_CLI_HOMEenvironment variable. This is wrong becauseGEMINI_CLI_HOMEis for configuring the config directory — it should not affect whether the user is literally in their OS home directory.Changes
packages/cli/src/utils/userStartupWarnings.tshomedir()(from@google/gemini-cli-core) withos.homedir()(fromnode:os)GEMINI_CLI_HOMEpackages/cli/src/utils/userStartupWarnings.test.tshomedir: () => os.homedir()mock passthrough (no longer needed)GEMINI_CLI_HOMEdiffers fromos.homedir()— no warningFixes #22309
How to Validate
npx vitest run packages/cli/src/utils/userStartupWarnings.test.ts— all tests passgeminifrom~— warning appears; from~/some-project— no warningRelated
userStartupWarnings.tsbut different concern)