From 7e05cde008c25940fb777ab1ae0c26c181692764 Mon Sep 17 00:00:00 2001 From: mi-wada <49638956+mi-wada@users.noreply.github.com> Date: Tue, 16 Nov 2021 00:29:34 +0900 Subject: cli: improve configuration failure mode This improves the error message printed when ripgrep can't read the file path pointed to by RIPGREP_CONFIG_PATH. Specifically, before this change: $ RIPGREP_CONFIG_PATH=no_exist_path rg 'search regex' no_exist_path: No such file or directory (os error 2) And now after this change: $ RIPGREP_CONFIG_PATH=no_exist_path rg 'search regex' failed to read the file specified in RIPGREP_CONFIG_PATH: no_exist_path: No such file or directory (os error 2) In the above examples, the first failure mode looks obvious, but that's only because RIPGREP_CONFIG_PATH is being set at the same time that we run the command. Often, the environment variable is set elsewhere and the error message could be confusing outside of that context. Closes #1990 --- crates/core/config.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/core/config.rs b/crates/core/config.rs index 5426554d..d9c5970b 100644 --- a/crates/core/config.rs +++ b/crates/core/config.rs @@ -28,7 +28,10 @@ pub fn args() -> Vec { let (args, errs) = match parse(&config_path) { Ok((args, errs)) => (args, errs), Err(err) => { - message!("{}", err); + message!( + "failed to read the file specified in RIPGREP_CONFIG_PATH: {}", + err + ); return vec![]; } }; -- cgit v1.2.3