Skip to content

fix: prevent false command conflicts when launching from home directory - #25950

Closed
stbenjam wants to merge 6 commits into
google-gemini:mainfrom
stbenjam:fix-false-command-conflicts-home-dir
Closed

fix: prevent false command conflicts when launching from home directory#25950
stbenjam wants to merge 6 commits into
google-gemini:mainfrom
stbenjam:fix-false-command-conflicts-home-dir

Conversation

@stbenjam

Copy link
Copy Markdown

Note: this is just cherry-picking #23069 and fixing the test failures.


Summary

When launching gemini from 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 unnecessary workspace. and user. 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 — Add path.resolve() comparison to deduplicate command directories
  • packages/cli/src/services/FileCommandLoader.test.ts — Add test case verifying deduplication when cwd equals home

How to Validate

  1. cd ~ (go to home directory)
  2. Create a custom command in ~/.gemini/commands/
  3. Run gemini — should no longer see false conflict warnings

Checklist

  • Tests added
  • Existing tests pass

Br1an67 and others added 4 commits March 19, 2026 13:27
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.
@stbenjam
stbenjam requested a review from a team as a code owner April 24, 2026 23:58
@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 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

  • Path Deduplication: Implemented a check in FileCommandLoader to prevent loading duplicate command directories when the workspace root is the same as the user home directory.
  • Conflict Resolution: Prevented false command conflict warnings by skipping the workspace directory if it resolves to the same location as the user commands directory.
  • Test Coverage: Added a new test case to verify that commands are loaded correctly and without duplication when the project root is set to the home directory.
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.

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.

@google-cla

google-cla Bot commented Apr 24, 2026

Copy link
Copy Markdown

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.

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

@stbenjam

Copy link
Copy Markdown
Author

I have to find someone internally to add me to the Google CLA for Red Hat.

@gemini-cli gemini-cli Bot added 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! labels Apr 25, 2026
@stbenjam stbenjam closed this Apr 25, 2026
@stbenjam stbenjam reopened this Apr 25, 2026
@stbenjam

Copy link
Copy Markdown
Author

CLA is done

@stbenjam

stbenjam commented May 7, 2026

Copy link
Copy Markdown
Author

Original PR got updated

@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! size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False command conflicts when launching from home directory (workspace and user commands resolve to same path)

4 participants