From 4e13b5374fc48685dbe9ad6cac1d28839d83d8a2 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi <9337627+albestro@users.noreply.github.com> Date: Sat, 25 Feb 2023 06:32:33 +0100 Subject: fix dump problem (#35673) if dump file existed it was not truncating the file, resulting in a file with unaltered filesize, with the new content at the beginning, "padded" with the tail of the old content, since the new content was not enough to overwrite it. --- lib/spack/spack/util/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py index c85b882253..cad8552f7b 100644 --- a/lib/spack/spack/util/environment.py +++ b/lib/spack/spack/util/environment.py @@ -138,7 +138,7 @@ def dump_environment(path, environment=None): use_env = environment or os.environ hidden_vars = set(["PS1", "PWD", "OLDPWD", "TERM_SESSION_ID"]) - fd = os.open(path, os.O_WRONLY | os.O_CREAT, 0o600) + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600) with os.fdopen(fd, "w") as env_file: for var, val in sorted(use_env.items()): env_file.write( -- cgit v1.2.3-60-g2f50