From b32105f4da17760b9a8e718895115ec7588101fb 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: [PATCH] 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 421a4b77d4e..0cc51e70fd7 100644 --- a/lib/spack/spack/util/environment.py +++ b/lib/spack/spack/util/environment.py @@ -141,7 +141,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(