diff options
-rw-r--r-- | lib/spack/spack/filesystem_view.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/spack/spack/filesystem_view.py b/lib/spack/spack/filesystem_view.py index 1b3c692958..5385ca0803 100644 --- a/lib/spack/spack/filesystem_view.py +++ b/lib/spack/spack/filesystem_view.py @@ -201,9 +201,13 @@ class YamlFilesystemView(FilesystemView): # Write projections file to new view # Not strictly necessary as the empty file is the empty # projection but it makes sense for consistency - mkdirp(os.path.dirname(projections_path)) - with open(projections_path, 'w') as f: - f.write(s_yaml.dump({'projections': self.projections})) + try: + mkdirp(os.path.dirname(projections_path)) + with open(projections_path, 'w') as f: + f.write(s_yaml.dump({'projections': self.projections})) + except OSError as e: + if self.projections: + raise e elif not os.path.exists(projections_path): # Write projections file to new view mkdirp(os.path.dirname(projections_path)) |