From e19cc2385e0dc1c7807736ec0bcdb1ffbc3ef694 Mon Sep 17 00:00:00 2001 From: psakiev Date: Thu, 1 Dec 2022 16:50:24 -0700 Subject: [PATCH] Don't automatically create the default env path --- lib/spack/spack/environment/environment.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 0f1a1d63c44..dc745739056 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -66,11 +66,6 @@ #: default path where environments are stored in the spack tree default_env_path = os.path.join(spack.paths.var_path, "environments") -# ensure that this base directory exists since we require the root directory to be created -# in our checks -if not os.path.isdir(default_env_path): - os.mkdir(default_env_path) - #: Name of the input yaml file for an environment manifest_name = "spack.yaml" @@ -271,10 +266,14 @@ def create(name, init_file=None, with_view=None, keep_relative=False): # double check that the root path exists before we check the full environment name # we need to be a bit more pedantic and not create automatically since this is a user # configurable path that can be subject to user input errors - raise SpackEnvironmentError( - "The environments_root '{er}' does not exist. Please create the directory or provide " - "a valid path in the config.yaml".format(er=env_root_path()) - ) + if env_root_path() == default_env_path: + # we can just create the default path since it is internal to spack + os.mkdir(default_env_path) + else: + raise SpackEnvironmentError( + "The environments_root '{er}' does not exist. Please create the directory or " + "provide a valid path in the config.yaml".format(er=env_root_path()) + ) validate_env_name(name) if exists(name): raise SpackEnvironmentError("'%s': environment already exists" % name)