pub fn document_root_warnings(
documents: &[String],
base_dir: Option<&Path>,
fs: &dyn FileSystem,
) -> Vec<OptionWarning>Expand description
Resolve documents roots against the ledger’s directory.
Ungated: the loader itself calls these to raise E7006, and it needs to do so
whether or not validation is on.
E7006 warnings for option "documents" roots that do not exist on disk.
The single source of truth for the check. Loader::load calls it with the
ledger’s directory; the LSP’s single-file fallback calls it with the open
buffer’s directory. It deliberately does NOT live in Options::set, which
has no base dir and so could only ever ask about the process CWD — that was
#1999, where rledger check sub/ledger.bean reported a document root that
was sitting right next to the ledger.
A None base_dir (an unsaved buffer with no path) checks only absolute
roots. Relative ones are skipped rather than guessed at, because the only
thing left to resolve them against is the CWD, and that is the bug.
Probing goes through fs rather than std::path::Path::exists so the
check honors the loader’s injected filesystem instead of reaching past it
to the host. That matters for in-memory loads: a VirtualFileSystem has
no directory entries, and a raw host probe would warn on every one.