#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

#351 in Configuration

Download history 10807/week @ 2024-11-08 12177/week @ 2024-11-15 11356/week @ 2024-11-22 11439/week @ 2024-11-29 10538/week @ 2024-12-06 9570/week @ 2024-12-13 4832/week @ 2024-12-20 4693/week @ 2024-12-27 8821/week @ 2025-01-03 12861/week @ 2025-01-10 9522/week @ 2025-01-17 8811/week @ 2025-01-24 10752/week @ 2025-01-31 10371/week @ 2025-02-07 5130/week @ 2025-02-14

27,526 downloads per month
Used in 35 crates (28 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