#root-directory #utils #path #config-directory #absolute #find #rootdir

project-root

Simple utility to return the absolute path to your project root

5 releases

0.2.2 Feb 16, 2021
0.2.1 Feb 16, 2021
0.2.0 Feb 16, 2021
0.1.1 Feb 11, 2021
0.1.0 Feb 11, 2021

#228 in Configuration

Download history 11487/week @ 2024-09-12 10868/week @ 2024-09-19 13194/week @ 2024-09-26 12107/week @ 2024-10-03 11910/week @ 2024-10-10 11207/week @ 2024-10-17 10903/week @ 2024-10-24 10191/week @ 2024-10-31 10769/week @ 2024-11-07 12099/week @ 2024-11-14 11823/week @ 2024-11-21 11215/week @ 2024-11-28 11035/week @ 2024-12-05 9514/week @ 2024-12-12 5788/week @ 2024-12-19 4437/week @ 2024-12-26

32,864 downloads per month
Used in 33 crates (27 directly)

MIT/Apache

4KB

project root

A simple utility to obtain the absolute path to your project root.

Usage

match project_root::get_project_root() {
    Ok(p) => println!("Current project root is {:?}", p),
    Err(e) => println!("Error obtaining project root {:?}", e)
};

Motivation

I was trying to slurp in some config files during a test but the directory location was not what I expected - and indeed would not be the final location of that directory on a deployment.

I couldn't find an immediately obvious way of finding out my position relative to the project root so built this little helper.


lib.rs:

project root

Helper to find the absolute root directory path of a project as it stands relative to the location of the nearest Cargo.lock file.

No runtime deps