spack / spack

A flexible package manager that supports multiple versions, configurations, platforms, and compilers.
https://spack.io
Other
4.26k stars 2.26k forks source link

Clingo loses external information in Specs #24506

Open Paul-Ferrell opened 3 years ago

Paul-Ferrell commented 3 years ago

In working on a new unittest for the checking spec install status, I discovered that when clingo concretizes a spec with an external_path defined that information is lost. This appears to happen because the spec objects generated by the Clingo solver don't maintain that information, and the original spec has those attributes overwritten by the concretized Spec via the ._dup() method. It's likely that other crucial information from the original Spec isn't preserved as well.

Steps to reproduce the issue

While using the clingo concretizer:

spec = Spec("myspec", external_path='/foo/bar')
print(spec.external_path, spec.external)
spec.concretize()
print(spec.external_path, spec.external)

Error Message

N/A

Information on your system

Clingo doesn't bootstrap on my system, so I ended up debugging this slowly through github unittests.

Additional information

alalazo commented 2 years ago

Posting here for reference @becker33 comment at https://github.com/spack/spack/pull/27128#discussion_r741272620

Going back to the original issue, it looks like the problem comes when synthetically constructing external specs that don't match the current configuration. I imagine it might also come up when concretizing an abstract spec with a concrete dependency (say, hdf5 ^mpich/abcdef) when the concrete dependency has external dependencies of its own. If the configuration has changed so that those dependencies aren't available externally anymore, I think we will fail to find the external_path value for them.