Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Entry point's crate directory
I've found out I can do one of the following to get the directory of the entry point crate being compiled:
// Option 1
let project_directory = std::env::current_dir().unwrap();
// Option 2
let project_directory = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
But neither are perfect. I want to be able to get the entry point's directory (not the workspace unless it's a workspace+package) from a third-party crate, and I want to support Cargo -p
... --manifest-path
...
7 posts - 2 participants
🏷️ Rust_feed