From 44f4ad7bbfcfb7da53a07fcd0f897db7ebf32448 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Thu, 8 Aug 2019 19:46:14 -0500 Subject: Allow Spack to uninstall external extensions without permissions (#11991) * Allow Spack to uninstall external extensions without permissions Raise when self.projections is not empty --- lib/spack/spack/filesystem_view.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib') 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)) -- cgit v1.2.3-60-g2f50