claude-code - 💡(How to fix) Fix Glob tool returns empty for path-prefixed patterns when path parameter is set [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47042Fetched 2026-04-13 05:43:01
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

Error Message

This is a silent failure — the tool returns "No files found" instead of an error, which makes it look authoritative. In practice this caused:

Root Cause

  • Claude Code CLI on macOS (Darwin 25.3.0, arm64)
  • Tested across multiple independent Next.js repos — same behavior in all
  • Not caused by .gitignore, file count, macOS quarantine/xattr, or node_modules size
  • The underlying glob libraries (glob, fast-glob) resolve these patterns correctly when tested independently via Node.js

Fix Action

Fix / Workaround

The workaround is to always set path to the target subdirectory and use patterns without path prefixes, but this is counterintuitive and undocumented.

RAW_BUFFERClick to expand / collapse

Bug Description

The Glob tool returns empty results for any pattern that contains a directory separator (/) when searching from a project root via the path parameter. Only root-level filenames and pure ** wildcard patterns work.

Minimal Reproduction

Given a repo with src/lib/scoring.ts:

PatternPathResult
src/lib/*.ts<repo root>Empty (bug)
*.ts<repo root>/src/libWorks
**/*.ts<repo root>Works (but includes node_modules)
src/lib/scoring.ts<repo root>Empty (bug — exact filename!)
CLAUDE.md<repo root>Works (root-level file)

Reproduction Steps

  1. Open any Next.js project with src/ directory structure
  2. Run Glob(pattern="src/lib/*.ts", path="/path/to/project") → returns "No files found"
  3. Run Glob(pattern="*.ts", path="/path/to/project/src/lib") → returns all files correctly
  4. Run Glob(pattern="src/components/**/*.tsx", path="/path/to/project") → returns "No files found"

Environment

  • Claude Code CLI on macOS (Darwin 25.3.0, arm64)
  • Tested across multiple independent Next.js repos — same behavior in all
  • Not caused by .gitignore, file count, macOS quarantine/xattr, or node_modules size
  • The underlying glob libraries (glob, fast-glob) resolve these patterns correctly when tested independently via Node.js

Impact

This is a silent failure — the tool returns "No files found" instead of an error, which makes it look authoritative. In practice this caused:

  • Wrongly concluding source files don't exist
  • Wasting ~20 minutes debugging a non-existent problem
  • Sending incorrect specs to collaborators based on "missing" files

The workaround is to always set path to the target subdirectory and use patterns without path prefixes, but this is counterintuitive and undocumented.

Secondary Issue

permissions.deny entries in .claude/settings.json (e.g., Glob(node_modules/**)) don't appear to filter results within the same session they're added. May require session restart, or the deny syntax may not apply to Glob results.

extent analysis

TL;DR

The Glob tool likely requires the path parameter to be set to the target subdirectory and patterns to be used without path prefixes to return correct results.

Guidance

  • Verify that the issue is not caused by the underlying file system or permissions by testing the glob patterns independently via Node.js, as mentioned in the Environment section.
  • Try setting the path parameter to the target subdirectory and using patterns without path prefixes, as described in the workaround.
  • Test the permissions.deny entries in .claude/settings.json to see if they filter results correctly after a session restart.
  • Consider documenting the workaround and the expected behavior of the Glob tool to avoid similar issues in the future.

Example

No code snippet is provided as it is not clearly supported by the issue.

Notes

The issue seems to be specific to the Glob tool and its interaction with the path parameter. The underlying glob libraries (glob, fast-glob) resolve the patterns correctly when tested independently.

Recommendation

Apply the workaround by setting the path parameter to the target subdirectory and using patterns without path prefixes, as it is the most straightforward solution to the problem. This approach allows for correct results to be returned without requiring significant changes to the Glob tool or its configuration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Glob tool returns empty for path-prefixed patterns when path parameter is set [1 comments, 2 participants]