pub fn resolve_project_root(
input: ProjectInput<'_>,
home: Option<&Path>,
) -> Option<PathBuf>Expand description
Resolve a project root from process-like path inputs without caching.
The fallback order is:
- Walk upward from the working directory set by
ProjectInput::cwd. - Walk upward from the parent directory of the executable set by
ProjectInput::exe, unless the executable is a known runtime or tool such asnode,python, orcargo. A known runtime inside a Python virtual environment (a directory withpyvenv.cfgone or two levels above the executable, as inapp/.venv/bin/pythonorapp\.venv\Scripts\python.exe) walks from the directory holding the environment instead. - Walk upward from the parent directory of each absolute path in the
arguments set by
ProjectInput::cmd.
The first accepted marker hit wins. Relative command-line paths are ignored
because they are ambiguous without a reliable process working directory.
home is the same optional ceiling as in find_project_root. A root
found from the executable path is rejected when it lies inside a dot
directory directly under home (~/.nvm, ~/.cargo, ~/.local): those
hold installed toolchains and packages, not the process’s project.
Use StackDetector::detect_project_root
for repeated lookups; it applies the same order with caching and its own
configured home ceiling.
§Examples
use what_stack::{ProjectInput, resolve_project_root};
assert_eq!(resolve_project_root(ProjectInput::new(), None), None);