fix: prevent false command conflicts when launching from home directory - #25950
fix: prevent false command conflicts when launching from home directory#25950stbenjam wants to merge 6 commits into
Conversation
When launching gemini from the user's home directory, both the user commands directory (~/.gemini/commands) and the workspace commands directory (<cwd>/.gemini/commands) resolve to the same path. This caused every custom command to appear as a conflict with itself, producing unnecessary 'workspace.' and 'user.' prefix warnings. The fix compares the resolved absolute paths of both command source directories in FileCommandLoader.getCommandDirectories(). If they point to the same location on disk, the workspace directory is skipped, preventing duplicate loading and false conflict detection. Fixes google-gemini#22929
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Remove unused `resolveToRealPath` and `normalizePath` imports from FileCommandLoader.ts that were causing eslint no-unused-vars and TypeScript TS6133 errors across all CI jobs.
Summary of ChangesHello, 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 launching the CLI from the user's home directory caused command loading conflicts. By identifying when the workspace directory and user commands directory overlap, the loader now correctly deduplicates these paths, ensuring that custom commands are loaded exactly once and eliminating unnecessary warnings. 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. Footnotes
|
|
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. |
There was a problem hiding this comment.
Code Review
This pull request prevents the duplication of commands when the project root is the user's home directory. It modifies FileCommandLoader to skip loading project commands if the workspace is identified as the home directory and adds a corresponding test case to verify this behavior. I have no feedback to provide.
|
I have to find someone internally to add me to the Google CLA for Red Hat. |
|
CLA is done |
|
Original PR got updated |
Note: this is just cherry-picking #23069 and fixing the test failures.
Summary
When launching
geminifrom the user home directory, both the user commands directory (~/.gemini/commands) and the workspace commands directory (<cwd>/.gemini/commands) resolve to the same path. This caused every custom command to appear as a conflict with itself, producing unnecessaryworkspace.anduser.prefix warnings.Fixes #22929
Details
The fix adds a path deduplication check in
FileCommandLoader.getCommandDirectories(). Before returning both directories, it compares their resolved absolute paths. If they point to the same location on disk, the workspace directory is skipped entirely — preventing duplicate loading and false conflict detection.Changed files:
packages/cli/src/services/FileCommandLoader.ts— Addpath.resolve()comparison to deduplicate command directoriespackages/cli/src/services/FileCommandLoader.test.ts— Add test case verifying deduplication when cwd equals homeHow to Validate
cd ~(go to home directory)~/.gemini/commands/gemini— should no longer see false conflict warningsChecklist