summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Invernizzi <9337627+albestro@users.noreply.github.com>2023-02-25 06:32:33 +0100
committerGitHub <noreply@github.com>2023-02-24 21:32:33 -0800
commit4e13b5374fc48685dbe9ad6cac1d28839d83d8a2 (patch)
tree9d3745c2e151cc62d127e002a1208bc6f3fd274a
parent07897900ebb1278113a696675a158ae6d5b3e41b (diff)
downloadspack-4e13b5374fc48685dbe9ad6cac1d28839d83d8a2.tar.gz
spack-4e13b5374fc48685dbe9ad6cac1d28839d83d8a2.tar.bz2
spack-4e13b5374fc48685dbe9ad6cac1d28839d83d8a2.tar.xz
spack-4e13b5374fc48685dbe9ad6cac1d28839d83d8a2.zip
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.
-rw-r--r--lib/spack/spack/util/environment.py2
1 files changed, 1 insertions, 1 deletions
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(