[BUG] Glob ignores .ignore/.rgignore by default (--no-ignore); should use --no-ignore-vcs so only .gitignore is skipped

Status Open
Reported on v2.1.283
Maintainer reply None cached
Activity 0 comments · opened Sep 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet (closest: #77488, which asked for ignore files in general and was stale-closed; see below)
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

What's Wrong?

With default settings the Glob tool ignores .ignore and .rgignore files as well as .gitignore. The docs say Glob "doesn't respect .gitignore by default" and that this is intended. They say nothing about .ignore/.rgignore, but those are dropped too, because the tool passes ripgrep --no-ignore, which disables every ignore source (in Claude Code 2.1.283 the args are --files --null --glob <pattern> --sort=modified --no-ignore --hidden, gated on CLAUDE_CODE_GLOB_NO_IGNORE, which defaults to "true").

.ignore/.rgignore are the files ripgrep and fd read specifically to keep search tools out of a directory. People use them to fence off trees that should never be walked, for example a FUSE/network mount (rclone, sshfs, NFS) or a huge generated directory. The Grep tool honors them. Glob does not, so a Glob from a parent directory walks straight into the fenced-off tree. On a network mount that means remote directory listings and, on some FUSE backends, downloads.

The only knob, CLAUDE_CODE_GLOB_NO_IGNORE=false, is all-or-nothing: it also makes Glob respect .gitignore, which is the behavior the docs say Glob intentionally avoids (gitignored build outputs, .env* and so on drop out of Glob results).

What Should Happen?

By default Glob should skip VCS ignore rules only (.gitignore, .git/info/exclude, the global git excludes file), as documented, and still honor .ignore/.rgignore. ripgrep supports this directly: --no-ignore-vcs instead of --no-ignore. CLAUDE_CODE_GLOB_NO_IGNORE=false would keep its current meaning (respect .gitignore too).

Error Messages/Logs

None. The tool returns the paths under the ignored directory.

Steps to Reproduce

mkdir -p /tmp/glob-repro/keep /tmp/glob-repro/mnt && cd /tmp/glob-repro
touch keep/a.txt mnt/huge.txt
printf 'mnt/\n' > .ignore

P="Call the Glob tool exactly once with pattern '**/*.txt' in the current directory and reply with only the raw list of paths it returned."
claude -p --tools=Glob "$P"
# mnt/huge.txt
# keep/a.txt          <- mnt/ is listed in .ignore but still walked

CLAUDE_CODE_GLOB_NO_IGNORE=false claude -p --tools=Glob "$P"
# keep/a.txt          <- correct, but now .gitignore is honored too

The same difference with ripgrep alone, using Glob's own arguments:

rg --files --glob '**/*.txt' --sort=modified --no-ignore     --hidden .   # ./mnt/huge.txt ./keep/a.txt
rg --files --glob '**/*.txt' --sort=modified --no-ignore-vcs --hidden .   # ./keep/a.txt

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.283 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Non-interactive/CI environment

Additional Information

Suggested fix: in the Glob argument builder, emit --no-ignore-vcs instead of --no-ignore when CLAUDE_CODE_GLOB_NO_IGNORE is true. That keeps the documented "Glob finds gitignored files" behavior while honoring .ignore/.rgignore, like Grep does. If exhaustive walks are still wanted, a separate value (for example CLAUDE_CODE_GLOB_NO_IGNORE=all) could keep today's --no-ignore. Please also mention .ignore/.rgignore in the Glob section of tools-reference and in the env-vars entry.

Related: #77488 asked for ignore files to be respected by default, mainly for performance. The reply there said skipping .gitignore is intended, and the issue was then stale-closed. This report is narrower: it keeps that intent and only asks that the search-tool ignore files, which have no VCS meaning, are honored.

View original on GitHub ↗