diff --git a/src/dfx-core/src/config/cache.rs b/src/dfx-core/src/config/cache.rs index dcd2d87c57..86ba006a53 100644 --- a/src/dfx-core/src/config/cache.rs +++ b/src/dfx-core/src/config/cache.rs @@ -44,7 +44,7 @@ pub fn get_cache_root(ensure_dir_exists: bool) -> Result { pub fn get_bin_cache_root(ensure_dir_exists: bool) -> Result { let p = get_cache_root(ensure_dir_exists)?.join("versions"); - if !p.exists() { + if !p.exists() && ensure_dir_exists { crate::fs::create_dir_all(&p).map_err(CacheError::CreateCacheDirectoryFailed)?; } else if !p.is_dir() { return Err(CacheError::FindCacheDirectoryFailed(p));