From 90fa50d9df0705f8a986d0281064fe1ed875a5e0 Mon Sep 17 00:00:00 2001 From: Pedro Demarchi Gomes Date: Mon, 4 Oct 2021 11:59:03 -0300 Subject: Avoid replacing symlinked spack.yaml when concretizing an environment (#26428) --- lib/spack/spack/environment.py | 2 +- lib/spack/spack/test/cmd/env.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-60-g2f50