diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index cc69463a982..bae4c4650c0 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -3,6 +3,7 @@ pub mod codegen; use std::{ + env, error::Error, fs, io::{Error as IoError, ErrorKind}, @@ -17,7 +18,13 @@ pub type Result = std::result::Result>; const TOOLCHAIN: &str = "stable"; pub fn project_root() -> PathBuf { - Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(1).unwrap().to_path_buf() + Path::new( + &env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| env!("CARGO_MANIFEST_DIR").to_owned()), + ) + .ancestors() + .nth(1) + .unwrap() + .to_path_buf() } pub struct Cmd<'a> {