Glob tool only returns files, not directories #7780

Open
opened 2026-02-16 18:08:12 -05:00 by yindo · 1 comment
Owner

Originally created by @felipemadero on GitHub (Jan 27, 2026).

Originally assigned to: @thdxr on GitHub.

Description

The glob tool uses rg --files (ripgrep) which only returns files, not directories. This causes patterns like dir/* to miss directory matches.

Steps to Reproduce

  1. Have a directory structure like:

    dir/
    ├── foo/          (directory)
    ├── bar/          (directory)
    └── readme.md     (file)
    
  2. Run glob with pattern dir/*

  3. Expected: Returns 3 matches (2 directories + 1 file)

  4. Actual: Returns 1 match (only the file)

Root Cause

Ripgrep.files() uses rg --files which by design only lists files, never directories. This is documented ripgrep behavior.

Proposed Solution

Use fd (sharkdp/fd) instead of ripgrep for the glob tool. fd returns both files and directories by default and has the same benefits:

  • Respects .gitignore
  • Fast parallel traversal
  • Same author ecosystem as ripgrep
Originally created by @felipemadero on GitHub (Jan 27, 2026). Originally assigned to: @thdxr on GitHub. ## Description The glob tool uses `rg --files` (ripgrep) which only returns files, not directories. This causes patterns like `dir/*` to miss directory matches. ## Steps to Reproduce 1. Have a directory structure like: ``` dir/ ├── foo/ (directory) ├── bar/ (directory) └── readme.md (file) ``` 2. Run glob with pattern `dir/*` 3. **Expected:** Returns 3 matches (2 directories + 1 file) 4. **Actual:** Returns 1 match (only the file) ## Root Cause `Ripgrep.files()` uses `rg --files` which by design only lists files, never directories. This is documented ripgrep behavior. ## Proposed Solution Use `fd` (sharkdp/fd) instead of ripgrep for the glob tool. `fd` returns both files and directories by default and has the same benefits: - Respects `.gitignore` - Fast parallel traversal - Same author ecosystem as ripgrep
Author
Owner

@github-actions[bot] commented on GitHub (Jan 27, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #10637: Empty directory cannot be found by '@' - Similar root cause where directories are not being returned by the glob/matching functionality
@github-actions[bot] commented on GitHub (Jan 27, 2026): This issue might be a duplicate of existing issues. Please check: - #10637: Empty directory cannot be found by '@' - Similar root cause where directories are not being returned by the glob/matching functionality
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7780