Skip to content

glob tool respects .gitignore #31994

Closed as not planned
Closed as not planned

Description

@Arcadi4

Summary

The glob tool runs rg --files --glob=<pattern> without --no-ignore, so anything in .gitignore is silently filtered out — even when the agent passes an exact path it already knows exists.

This makes sense for grep (gitignored matches would flood context with node_modules/dist noise). It doesn't make sense for glob, which only returns paths. The cost of including a gitignored hit is one line; the cost of hiding it is the agent asserting a file doesn't exist when it does.

Reproduction

Just using this repo as example, on dev after bun install, ask your agent to run:

$ ls packages/opencode/node_modules/effect/package.json   # exists
glob("packages/opencode/node_modules/effect/package.json") # I → No files found
glob("**/node_modules/effect/package.json")                → No files found

Same for dist/, tmp/, logs/, .env*, *.tsbuildinfo. Inconsistent with --hidden, which the same call passes — hidden files are returned, gitignored files are not.

Common cases this breaks:

  • "Find the built bundle" → dist/**/*.js returns nothing
  • "Where does effect define X?" → **/node_modules/effect/** returns nothing
  • "Find generated SDK / codegen output" → invisible

Code

packages/core/src/ripgrep.ts:157-170:

glob: (input) =>
  run<string>({
    cwd: input.cwd,
    args: [
      "--no-config",
      "--files",
      ...(input.hidden ? ["--hidden"] : []),
      ...(input.follow ? ["--follow"] : []),
      `--glob=${input.pattern}`,
      "--glob=!**/.git/**",
      ".",
    ],
    ...
  })

Suggestion

Add --no-ignore-vcs to the glob argv (keep --glob=!**/.git/**), leave grep as-is. Optionally expose respectGitignore on the tool for opt-back-in.

Happy to PR.

Activity

  1. changed the title [-]More consideration on `ripgrep` strategies[/-] [+]glob tool hides files matching gitignore — returns "No files found" for files that exist on disk[/+] on Jun 12, 2026
  2. changed the title [-]glob tool hides files matching gitignore — returns "No files found" for files that exist on disk[/-] [+]glob tool respects .gitignore[/+] on Jun 12, 2026
  3. github-actions commented on Aug 17, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions