Codex CLI: file references report 'no matches' even for existing files in CWD

Resolved 💬 3 comments Opened Dec 30, 2025 by vforsh Closed Dec 30, 2025
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

Problem
In Codex CLI I try to reference files that definitely exist in the current working directory / repo, but Codex responds with "no matches".

Examples

  • In a repo where src/GameScaler.ts exists, attempting to reference it via @GameScaler in chat yields "no matches".

Expected behavior

  • When a user references an existing file path (relative to repo root or CWD), Codex should resolve it and include it as context (or at minimum provide a clear error explaining the required syntax / root).

Actual behavior

  • Codex replies with "no matches" even though the file exists.

Environment

  • Product: Codex CLI
  • Version: codex-cli 0.77.0
  • OS: macOS 15.5 (24F74), arm64
  • Terminal: Ghostty 1.2.3

View original on GitHub ↗

3 Comments

etraut-openai contributor · 8 months ago

Is the target file included in a .gitignore? If so, that's covered by https://github.com/openai/codex/issues/2952.

Otherwise, this appears to be a duplicate of https://github.com/openai/codex/issues/3493.

vforsh · 7 months ago

Findings: /mention file search was only returning 2 files because global gitignore (~/.gitignore) contains '' which ignores everything. ignore crate logs show entries skipped with source /Users/vlad/.gitignore pattern ''. Removing the '' line restores full traversal. Debug line example: "ignore::walk: ignoring … Gitignore(Glob { from: Some("/Users/vlad/.gitignore"), original: "", actual: "**/*" })". For local repro, set RUST_LOG=codex_file_search=debug,ignore=debug and check ~/.codex/log/codex-tui.log. Root cause is user-level gitignore, not TUI.

vforsh · 7 months ago

More detail / fix steps:

  • Symptom: /mention suggestions show only a couple of files (e.g. README.md + .gitignore).
  • Root cause: the file search uses the ignore crate (ripgrep-like) and respects global gitignore rules by default. If your global ignore file contains a catch-all like '*', the walker will ignore almost everything.
  • In my repro, /mention search_dir=/Users/vlad/dev/codex/codex-rs reported file_entries=2 because entries were skipped by /Users/vlad/.gitignore with pattern '*'. Example log:

ignore::walk: ignoring … Gitignore(Glob { from: Some("/Users/vlad/.gitignore"), original: "", actual: "*/*" }).

How to confirm:

  • Run with RUST_LOG=codex_file_search=debug,ignore=debug and inspect ~/.codex/log/codex-tui.log for ignore::walk "ignoring …" lines showing the rule source.

How to fix:

  • Remove/adjust the catch-all '*' from your global gitignore (commonly ~/.gitignore or ~/.config/git/ignore depending on your setup).
  • After removing that rule, /mention suggestions populate normally.

Potential product hardening (optional): consider disabling global gitignore (git_global=false) for /mention file search, or add a fallback when file_entries is suspiciously low.