Allow Spack to uninstall external extensions without permissions (#11991)

* Allow Spack to uninstall external extensions without permissions

Raise when self.projections is not empty
This commit is contained in:
Adam J. Stewart 2019-08-08 19:46:14 -05:00 committed by Greg Becker
parent 0b4e13c034
commit 44f4ad7bbf

View File

@ -201,9 +201,13 @@ def __init__(self, root, layout, **kwargs):
# 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))