Search CLI returns nothing with large vault - not even 'no results'

Once you’ve done the above, delete everything above this line.

Here’s the final report with your debug info:


Steps to reproduce

  1. Open a vault containing a large number of files (~2,700+)
  2. Confirm GUI search works: open the search pane (Ctrl+Shift+F) and search for a common word (e.g. “hello”) — results appear as expected
  3. From a terminal, run: obsidian search query=hello
  4. Observe: no output is returned, exit code 0
  5. Open a small vault (e.g. the Sandbox vault or a new vault with 1–2 notes)
  6. Run: obsidian search query=hello vault="Obsidian Sandbox"
  7. Observe: results are returned correctly

Did you follow the troubleshooting guide? [Y]

Tested with:

  • Restricted mode enabled (all community plugins disabled)
  • Default theme, no CSS snippets
  • Search index rebuilt
  • Full restart of Obsidian
  • Sandbox vault as control (CLI search works there)

Expected result

obsidian search query=hello should return a list of matching files, consistent with the GUI search results.

Actual result

The CLI search command returns empty output with exit code 0 on a vault with ~2,740 files. The same command works correctly on small vaults (1–20 files). GUI search works correctly on all vaults.

Additionally, triggering a search via the JavaScript API (eval) confirms the search engine itself is functional:

obsidian eval code="app.workspace.getLeavesOfType('search')[0].view.setQuery('hello')"
obsidian eval code="app.workspace.getLeavesOfType('search')[0].view.dom.resultDomLookup.size"
=> 12

This suggests the CLI search command uses a different code path that does not wait for the search to complete on larger vaults (possible race condition / missing await).

Environment

Obsidian version: 1.12.4
Installer version: 1.12.4
Operating system: Windows 11 Pro 10.0.26200
Login status: logged in
Language: en-GB
Catalyst license: none
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: Vanilla AMOLED 1.0.0
Snippets enabled: 1
Restricted mode: on

Additional information

  • Vault contains ~2,740 markdown files across 141 folders
  • The search total flag also returns empty (not even “0”)
  • Occasionally the CLI returns “No matches found.” instead of empty output, but still no actual results
  • All other CLI commands (files, tags, tasks, read, vault) work correctly on the same vault
  • The issue does not appear to be related to userIgnoreFilters in app.json — tested with and without
  • Tested with community theme disabled as well — no change

We have made some changes to the way the CLI works and I am unable to reproduce.
When Obsidian 1.12.7 is released, download and reinstall Obsidian.

It the problem still happens, open a new BR, and attach a screen recording of this happening.

Also, vault= must be the first argument.

Per the doc: Obsidian CLI > Target a vault, vault= ...

[ … ] must be the first parameter before your command.

… otherwise I think it falls back on targeting the vault currently focused in Obsidian (GUI)

So, if you’re not targeting the appropriate vault with your command (because vault= ... is misplaced), this could potentially explain why it’s failing :woman_shrugging:

Edit: Please, don’t mind me :sweat_smile: … I just saw WhiteNoise’s reply :laughing:

Thanks for this - will do.

Perhaps unrelated, but it now returns as this. I can only think it could be because I kept obsidian open when sleeping the PC? I have no idea if this is the same issue or a new one.

Bash(obsidian vault=Chimaera folders folder=Home)

[39200:0322/161205.635:ERROR:chrome\browser\process_s
ingleton_win.cc:454] Lock file can not be created!
Error code: 32

Scratch this. I have no idea what I’m doing lol. Seems to be working again.

Reviving this thread because I can still reproduce the issue on 1.13.1 with installer 1.12.7 — the version that was expected to fix it.

**Environment:** macOS (Apple Silicon), Obsidian 1.13.1, installer 1.12.7 (bundled CLI binary), vault with ~3,600 markdown files. Single running app instance; core Search plugin enabled; `dev:errors` clean.

**Symptoms — nondeterministic across consecutive runs against the same app process:**

  • `obsidian search query=“term”` → usually **empty stdout, exit 0**. It returns fast (0.3–0.6 s over timed runs), so it’s not a timeout — the search engine doesn’t appear to be consulted at all.
  • Sometimes the same command returns `No matches found.` — wrong, the term has hundreds of hits in the GUI.
  • Occasionally the process **hangs** (>12 s, zero output) — no pipes involved, output redirected to a file.
  • `search query=… total` is tri-state across runs: empty string / `0` / never the real count.
  • **Control test:** the identical command on the small Sandbox vault returns 17 results, deterministically. This rules out syntax or vault-targeting errors (`vault=` passed as first argument).
  • GUI search and plugin JS APIs return correct results — only the CLI search path fails.
  • A graceful app restart **fixed `backlinks`** (it also returned empty before) but did **not** fix `search`/`search:context`.

This matches the original report: large-vault-only, empty with exit 0, GUI unaffected — consistent with the CLI search path not awaiting search completion. Possibly the 1.12.3 fix “CLI: Fixed the CLI hanging for some longer content” regressing on large vaults.

Happy to provide `dev:console` dumps captured during failing runs, a screen recording of consecutive nondeterministic runs, or to test a patched build.