diff --git a/lib/cli-compiler/src/commands/config.rs b/lib/cli-compiler/src/commands/config.rs index 0826e94212f..155fb0c1dde 100644 --- a/lib/cli-compiler/src/commands/config.rs +++ b/lib/cli-compiler/src/commands/config.rs @@ -46,10 +46,15 @@ impl Config { fn inner_execute(&self) -> Result<()> { let key = "WASMER_DIR"; let wasmer_dir = env::var(key) - .or_else(|e| { - option_env!("WASMER_INSTALL_PREFIX") - .map(str::to_string) - .ok_or(e) + .ok() + .or_else(|| option_env!("WASMER_INSTALL_PREFIX").map(str::to_string)) + .or_else(|| { + // Allowing deprecated function home_dir since it works fine, + // and will never be removed from std. + #[allow(deprecated)] + let dir = std::env::home_dir()?.join(".wasmer").to_str()?.to_string(); + + Some(dir) }) .context(format!( "failed to retrieve the {} environment variables", diff --git a/lib/cli/src/commands/config.rs b/lib/cli/src/commands/config.rs index 70b701448b9..0de850a6839 100644 --- a/lib/cli/src/commands/config.rs +++ b/lib/cli/src/commands/config.rs @@ -165,6 +165,7 @@ impl Config { self.inner_execute() .context("failed to retrieve the wasmer config".to_string()) } + fn inner_execute(&self) -> Result<()> { if let Some(s) = self.set.as_ref() { return s.execute(); @@ -174,10 +175,15 @@ impl Config { let key = "WASMER_DIR"; let wasmer_dir = env::var(key) - .or_else(|e| { - option_env!("WASMER_INSTALL_PREFIX") - .map(str::to_string) - .ok_or(e) + .ok() + .or_else(|| option_env!("WASMER_INSTALL_PREFIX").map(str::to_string)) + .or_else(|| { + // Allowing deprecated function home_dir since it works fine, + // and will never be removed from std. + #[allow(deprecated)] + let dir = std::env::home_dir()?.join(".wasmer").to_str()?.to_string(); + + Some(dir) }) .context(format!( "failed to retrieve the {} environment variables",