From a268e825aa9632b85732b19a6189b0672f3227fd Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 11 Jun 2020 10:50:57 -0700 Subject: [PATCH] Allow config to be readonly (#1967) --- crates/nu-cli/src/data/config.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/nu-cli/src/data/config.rs b/crates/nu-cli/src/data/config.rs index 5bda300d14..fbd296f27d 100644 --- a/crates/nu-cli/src/data/config.rs +++ b/crates/nu-cli/src/data/config.rs @@ -65,7 +65,11 @@ pub fn read( Some(ref file) => file.clone(), }; - touch(&filename)?; + if !filename.exists() && touch(&filename).is_err() { + // If we can't create configs, let's just return an empty indexmap instead as we may be in + // a readonly environment + return Ok(IndexMap::new()); + } trace!("config file = {}", filename.display());