From 32fef364ef67ab82d637b625774674dadbc1c8cd Mon Sep 17 00:00:00 2001 From: Tal Pressman Date: Tue, 15 Aug 2023 08:08:00 +0900 Subject: [PATCH] add error message when running from a non-existent directory --- cli/src/cli_util.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 6672db662..634b4b4ca 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -2664,7 +2664,12 @@ impl CliRunner { ui: &mut Ui, mut layered_configs: LayeredConfigs, ) -> Result<(), CommandError> { - let cwd = env::current_dir().unwrap(); // TODO: maybe map_err to CommandError? + let cwd = env::current_dir().map_err(|_| { + user_error_with_hint( + "Could not determine current directory", + "Did you check-out a commit where the directory doesn't exist?", + ) + })?; layered_configs.read_user_config()?; let config = layered_configs.merge(); ui.reset(&config)?;