diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 3ce40ef6feb9..fad3ec49da75 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -27,8 +27,8 @@ use opts::{Opts, Subcommands, ToBaseArgs}; #[tokio::main] async fn main() -> Result<()> { - utils::load_dotenv(); handler::install()?; + utils::load_dotenv(); utils::subscriber(); utils::enable_paint(); diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 5651dac409a7..595fa18a6174 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -2,6 +2,7 @@ use crate::Config; use alloy_primitives::U256; +use eyre::WrapErr; use figment::value::Value; use foundry_compilers::{ remappings::{Remapping, RemappingError}, @@ -33,10 +34,14 @@ pub fn load_config_with_root(root: Option) -> Config { /// Returns the path of the top-level directory of the working git tree. If there is no working /// tree, an error is returned. pub fn find_git_root_path(relative_to: impl AsRef) -> eyre::Result { + let path = relative_to.as_ref(); let path = std::process::Command::new("git") .args(["rev-parse", "--show-toplevel"]) - .current_dir(relative_to.as_ref()) - .output()? + .current_dir(path) + .output() + .wrap_err_with(|| { + format!("Failed detect git root path in current dir: {}", path.display()) + })? .stdout; let path = std::str::from_utf8(&path)?.trim_end_matches('\n'); Ok(PathBuf::from(path)) diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 08f1afefc168..e4489ec8277d 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -10,8 +10,8 @@ use cmd::{cache::CacheSubcommands, generate::GenerateSubcommands, watch}; use opts::{Opts, Subcommands}; fn main() -> Result<()> { - utils::load_dotenv(); handler::install()?; + utils::load_dotenv(); utils::subscriber(); utils::enable_paint();