diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2018-10-11 00:35:06 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2018-11-09 00:31:24 -0800 |
commit | 15c5c36eafa41aca9267581b1e00fdce67cc4b36 (patch) | |
tree | a556b9fe91b92e5d0fe041b0510ce0e7cd268621 /lib | |
parent | ce230fa3f45afc212d286e7e9a3c9ed4d0011f69 (diff) | |
download | spack-15c5c36eafa41aca9267581b1e00fdce67cc4b36.tar.gz spack-15c5c36eafa41aca9267581b1e00fdce67cc4b36.tar.bz2 spack-15c5c36eafa41aca9267581b1e00fdce67cc4b36.tar.xz spack-15c5c36eafa41aca9267581b1e00fdce67cc4b36.zip |
env: bugfix: spack env list won't fail if var/spack/environments doesn't exist
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/environment.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index bb7a50143d..06791ea2be 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -155,10 +155,15 @@ def config_dict(yaml_data): def list_environments(): """List the names of environments that currently exist.""" + # just return empty if the env path does not exist. A read-only + # operation like list should not try to create a directory. + if not os.path.exists(env_path): + return [] + candidates = sorted(os.listdir(env_path)) names = [] for candidate in candidates: - yaml_path = os.path.join(env_path, candidate, env_yaml_name) + yaml_path = os.path.join(root(candidate), env_yaml_name) if valid_env_name(candidate) and os.path.exists(yaml_path): names.append(candidate) return names |