Agent Grep and Glob tools return zero results for all calls

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

In Cursor’s agent, Grep and Glob behave as if the workspace were empty: no line matches and no file paths, even for simple patterns that should hit real files.

Steps to Reproduce

  1. Open any repository
  2. Ask Cursor: “I’m trying to confirm a bug in the Grep and Glob tools - can do a couple tool calls that should clearly produce results and tell me if they work?”

My result:
Grep: “No matches found” for common strings and broad path/glob usage.
Glob: “0 files” for the same root and subfolders where files clearly exist.

Expected Behavior

Grep should find text that exists in files; Glob should return paths that match the pattern (e.g. by extension or **/*).

Operating System

MacOS

Version Information

Version: 3.1.17 (Universal)
VSCode Version: 1.105.1
Commit: fce1e9ab7844f9ea35793da01e634aa7e50bce90
Date: 2026-04-19T19:33:58.189Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Darwin arm64 25.3.0

Additional Information

The shell (find / ls) shows a normal tree with many source and config files.
The same agent can still get useful hits via SemanticSearch (or Read) for the same codebase, so the failure is not “no project visible to the agent,” it’s specific to Grep/Glob.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

This is a known bug class with a few possible causes. The most common is the use of nested Git repositories. If your workspace contains subdirectories with their own .git/folders that aren’t registered as submodules (no .gitmodules entry), the agent’s Grep and Glob tools can’t see files in those subdirectories. Other tools like Shell, Read, and SemanticSearch bypass this and work fine, which matches what you’re seeing.

You may also find this related thread helpful – same symptoms.

Two things to try right away:

  1. Resync your codebase index - open the Command Palette (Cmd+Shift+P) and run “Cursor: Resync Index”. A stale index can cause Grep/Glob to return empty results even when files exist.

  2. Add a fallback rule in .cursor/rules (create the folder if it doesn’t exist) so the agent uses Shell for search:

When searching for files or code in this project, prefer using terminal commands (rg, find, grep) via the Shell tool instead of the built-in Grep/Glob tools, as they currently don’t handle certain workspace configurations correctly.

Since you mention this affects any repository you open, could you confirm whether your workspaces typically contain subdirectories with their own .git/ folder (nested repos not registered as git submodules)? That helps us narrow the root cause. If they’re simple single-root Git repos without nesting and resyncing the index doesn’t help, let me know, and we’ll dig deeper.

1 Like

Interesting. None of the repositories I’ve tried this with have any .git subdirectories other than the root one. I DO have a .git in my homedir (a parent of the CWD) - would that cause a problem? Testing…

Ah! Yes, if I copy a repo to another location (not under my homedir), it works fine! So… is there a way to tell Cursor to ignore the .git repo above the one it’s currently opened in? Or… I haven’t had any other issues with this configuration, but maybe there’s a better/cleaner way to version control my homedir without turning all subdirs into part of the repo that have to be ignored? (I do have a .gitignore in my homedir that ignores everything but a few files)

Ah! I just discovered this alternative (better) way to version my dotfiles, which seems like a potential solution. I’d still be interested to know if there’s a simple cursor-specific solution or not though!