Skip to main content

resolve_project_root

Function resolve_project_root 

Source
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:

  1. Walk upward from the working directory set by ProjectInput::cwd.
  2. Walk upward from the parent directory of the executable set by ProjectInput::exe.
  3. Walk upward from the parent directory of each absolute path in the arguments set by ProjectInput::cmd.

The first 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.

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);