From 2e6d9bd794f5b4a31c03874badceff3ed71e5daa Mon Sep 17 00:00:00 2001 From: Hunter Wittenborn Date: Mon, 3 Jun 2024 18:48:38 -0500 Subject: [PATCH] Fix unfound manifest error when `CARGO_TARGET_DIR` is set --- build.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index bbaaf7d..1c2ab1f 100644 --- a/build.rs +++ b/build.rs @@ -49,7 +49,8 @@ fn path_to_icon_name(string: &OsStr) -> String { fn main() { let out_dir = env::var("OUT_DIR").unwrap(); - let mut manifest_dir = Path::new(&out_dir).canonicalize().unwrap(); + let manifest_dir = env::var("PWD").unwrap(); + let mut manifest_path = Path::new(&manifest_dir).canonicalize().unwrap(); eprintln!("Canonical manifest dir: {manifest_dir:?}"); let (config, config_dir) = if cfg!(docsrs) { @@ -63,12 +64,12 @@ fn main() { // of the user. // Unfortunately, the CARGO_MANIFEST_DIR env var passed by cargo always points // to this crate, so we wouldn't find the users config file this way. - while !manifest_dir.join("Cargo.toml").exists() { - if !manifest_dir.pop() { + while !manifest_path.join("Cargo.toml").exists() { + if !manifest_path.pop() { panic!("Couldn't find your manifest directory"); } } - let config_dir = manifest_dir + let config_dir = manifest_path .to_str() .expect("Couldn't convert manifest directory to string") .to_owned();