diff options
author | Pedro Demarchi Gomes <pedrodemargomes@gmail.com> | 2021-10-04 11:59:03 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-04 14:59:03 +0000 |
commit | 90fa50d9df0705f8a986d0281064fe1ed875a5e0 (patch) | |
tree | ca34de08ac129058a60f798718f838b7b20fea8c /lib | |
parent | 4ae71b0297f71e6f50a0ba86cbb61e7861e6e1b9 (diff) | |
download | spack-90fa50d9df0705f8a986d0281064fe1ed875a5e0.tar.gz spack-90fa50d9df0705f8a986d0281064fe1ed875a5e0.tar.bz2 spack-90fa50d9df0705f8a986d0281064fe1ed875a5e0.tar.xz spack-90fa50d9df0705f8a986d0281064fe1ed875a5e0.zip |
Avoid replacing symlinked spack.yaml when concretizing an environment (#26428)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/environment.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/env.py | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index 7a9a4735fc..330d90915e 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -1944,7 +1944,7 @@ class Environment(object): written = os.path.exists(self.manifest_path) if changed or not written: self.raw_yaml = copy.deepcopy(self.yaml) - with fs.write_tmp_and_move(self.manifest_path) as f: + with fs.write_tmp_and_move(os.path.realpath(self.manifest_path)) as f: _write_yaml(self.yaml, f) def __enter__(self): diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index d9d6f5483c..10b9dee981 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -248,6 +248,25 @@ def test_env_install_same_spec_twice(install_mockery, mock_fetch): assert 'already installed' in out +def test_env_definition_symlink(install_mockery, mock_fetch, tmpdir): + filepath = str(tmpdir.join('spack.yaml')) + filepath_mid = str(tmpdir.join('spack_mid.yaml')) + + env('create', 'test') + e = ev.read('test') + e.add('mpileaks') + + os.rename(e.manifest_path, filepath) + os.symlink(filepath, filepath_mid) + os.symlink(filepath_mid, e.manifest_path) + + e.concretize() + e.write() + + assert os.path.islink(e.manifest_path) + assert os.path.islink(filepath_mid) + + def test_env_install_two_specs_same_dep( install_mockery, mock_fetch, tmpdir, capsys): """Test installation of two packages that share a dependency with no |