From a60c71b4b2a0a3f059efccef1d2615f4657cad63 Mon Sep 17 00:00:00 2001 From: Marc Mengel Date: Fri, 19 Jan 2024 10:42:27 -0600 Subject: [PATCH] readonly patch part 2 --- lib/spack/spack/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index 60aa946dfa8207..300533130aa6df 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -160,6 +160,7 @@ def _write_section(self, section): else: raise ConfigFileError(f"cannot write to '{filename}'") from e + def clear(self): """Empty cached config information.""" self.sections = syaml.syaml_dict() @@ -288,7 +289,11 @@ def _write_section(self, section): rename(tmp, self.path) except (syaml.SpackYAMLError, IOError) as e: - raise ConfigFileError(f"cannot write to config file {str(e)}") from e + if hasattr(e, 'errno') and e.errno in [13, 30]: + tty.warn("Ignoring write error on readonly %s" % filename) + else: + raise ConfigFileError(f"cannot write to '{filename}'") from e + def __repr__(self): return "" % (self.name, self.path)