#root #root-directory #utils #path #find #absolute #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

#202 in Configuration

Download history 4795/week @ 2024-01-07 5323/week @ 2024-01-14 6827/week @ 2024-01-21 5648/week @ 2024-01-28 7280/week @ 2024-02-04 6440/week @ 2024-02-11 5472/week @ 2024-02-18 4696/week @ 2024-02-25 4752/week @ 2024-03-03 5142/week @ 2024-03-10 6338/week @ 2024-03-17 6526/week @ 2024-03-24 7345/week @ 2024-03-31 7089/week @ 2024-04-07 7507/week @ 2024-04-14 6836/week @ 2024-04-21

29,210 downloads per month
Used in 26 crates (22 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