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.

1 Like

Also, vault= must be the first argument.

1 Like

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:

1 Like

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.