From 65b36bab1d896fb9fe2778c5957eb4ecbb22f719 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 15 Aug 2023 17:40:20 +0100 Subject: [PATCH 1/2] fix: Prevent panic when passing relative paths to `--program-dir` --- crates/nargo_cli/src/cli/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/nargo_cli/src/cli/mod.rs b/crates/nargo_cli/src/cli/mod.rs index df5eed7b297..9a97995e5ec 100644 --- a/crates/nargo_cli/src/cli/mod.rs +++ b/crates/nargo_cli/src/cli/mod.rs @@ -40,7 +40,7 @@ struct NargoCli { #[derive(Args, Clone, Debug)] pub(crate) struct NargoConfig { // REMINDER: Also change this flag in the LSP test lens if renamed - #[arg(long, hide=true, global=true, default_value_os_t = std::env::current_dir().unwrap())] + #[arg(long, hide = true, global = true, default_value = "./")] program_dir: PathBuf, } @@ -64,6 +64,11 @@ enum NargoCommand { pub(crate) fn start_cli() -> eyre::Result<()> { let NargoCli { command, mut config } = NargoCli::parse(); + // If the provided `program_dir` is relative, make it absolute by joining it to the current directory. + if !config.program_dir.is_absolute() { + config.program_dir = std::env::current_dir().unwrap().join(config.program_dir) + } + // Search through parent directories to find package root if necessary. if !matches!(command, NargoCommand::New(_) | NargoCommand::Init(_) | NargoCommand::Lsp(_)) { config.program_dir = find_package_root(&config.program_dir)?; From 2c0c1ec91b70cc0f511b586bd735299602369fef Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 15 Aug 2023 18:03:18 +0100 Subject: [PATCH 2/2] chore: clippy --- crates/nargo_cli/src/cli/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nargo_cli/src/cli/mod.rs b/crates/nargo_cli/src/cli/mod.rs index 9a97995e5ec..2603db3ce19 100644 --- a/crates/nargo_cli/src/cli/mod.rs +++ b/crates/nargo_cli/src/cli/mod.rs @@ -66,7 +66,7 @@ pub(crate) fn start_cli() -> eyre::Result<()> { // If the provided `program_dir` is relative, make it absolute by joining it to the current directory. if !config.program_dir.is_absolute() { - config.program_dir = std::env::current_dir().unwrap().join(config.program_dir) + config.program_dir = std::env::current_dir().unwrap().join(config.program_dir); } // Search through parent directories to find package root if necessary.