From dd8a2d65c04ab71124d7df9046402d422615b76f Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 26 Mar 2022 13:21:40 +0100 Subject: [PATCH] Add error message to CARGO_MANIFEST_DIR handling Since this is now no longer enforced at compile time. #6 --- nih_plug_xtask/src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nih_plug_xtask/src/lib.rs b/nih_plug_xtask/src/lib.rs index bfd789cd..b91221fc 100644 --- a/nih_plug_xtask/src/lib.rs +++ b/nih_plug_xtask/src/lib.rs @@ -103,10 +103,11 @@ pub fn main_with_args(command_name: &str, mut args: impl Iterator /// Change the current directory into the Cargo workspace's root. pub fn chdir_workspace_root() -> Result<()> { - let cargo_manifest_dir = std::env::var("CARGO_MANIFEST_DIR")?; - let project_root = Path::new(&cargo_manifest_dir) - .parent() - .context("Could not find project root")?; + let xtask_project_dir = std::env::var("CARGO_MANIFEST_DIR") + .context("'$CARGO_MANIFEST_DIR' was not set, are you running this binary directly?")?; + let project_root = Path::new(&xtask_project_dir).parent().context( + "'$CARGO_MANIFEST_DIR' has an unexpected value, are you running this binary directly?", + )?; std::env::set_current_dir(project_root).context("Could not change to project root directory") }