Skip to content

[Core] Handle EISDIR error when GEMINI.md is a directory during memory discovery #16282

@sontoriyama

Description

@sontoriyama

What happened?

Description

The memory discovery process in the CLI currently attempts to read files named GEMINI.md. However, if a directory exists with the same name (GEMINI.md), the fs.readFile operation fails with an EISDIR error, which triggers unnecessary warnings in the logs.

Proposed Solution

Implement an EAFP pattern in packages/core/src/utils/memoryDiscovery.ts to attempt reading the file and catch the EISDIR error. If a directory is found, it should be skipped silently or logged as a debug message. This avoids potential TOCTOU (Time-of-check to time-of-use) race conditions and handles symlinks more robustly.

This issue is related to PR #15866.

What did you expect to happen?

The memory discovery process should skip directories named GEMINI.md silently. It should not throw an EISDIR error or show warnings to the user, as directories with that name are valid in certain project structures and should simply be ignored in favor of actual files.

Client information

Client Information
> /about
- Version: 0.25.0-nightly.20260107.59a18e710
- Platform: Windows
- Node.js: v24.7.0

Login information

No response

Anything else we need to know?

No response

Metadata

Metadata

Assignees

Labels

area/coreIssues related to User Interface, OS Support, Core Functionalityhelp wantedWe will accept PRs from all issues marked as "help wanted". Thanks for your support!priority/p2Important but can be addressed in a future release.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions