From 77ceca877ab02cf5c489b261527356e17ba97975 Mon Sep 17 00:00:00 2001 From: Nanook Claw Date: Mon, 18 May 2026 00:11:04 +0000 Subject: [PATCH] fix: validate --app-config path early with clear error Closes #42 --- crates/nemo/src/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/nemo/src/main.rs b/crates/nemo/src/main.rs index 9c5db6a..6dda64e 100644 --- a/crates/nemo/src/main.rs +++ b/crates/nemo/src/main.rs @@ -54,6 +54,32 @@ fn main() -> Result<()> { // Load NemoConfig (config.toml) let nemo_config = NemoConfig::load_from(args.config.as_ref()); + // Validate app_config path early so we fail fast with a clear message + // before any subsystem (runtime, recent-projects, etc.) tries to use it. + if let Some(ref app_config) = args.app_config { + // For relative paths, resolution against the current directory is + // implicit in Path::exists/is_file. If current_dir() fails we can + // still check the path as supplied; either way the error message + // shows the original path the user passed. + let resolved = if app_config.is_relative() { + match std::env::current_dir() { + Ok(cwd) => cwd.join(app_config), + Err(_) => app_config.clone(), + } + } else { + app_config.clone() + }; + + if !resolved.exists() { + eprintln!("Error: config file not found: {}", app_config.display()); + std::process::exit(1); + } + if !resolved.is_file() { + eprintln!("Error: config path is not a file: {}", app_config.display()); + std::process::exit(1); + } + } + // If app_config is provided via CLI/env, handle headless/validate modes if let Some(ref app_config) = args.app_config { if args.headless || args.validate_only {