alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
278 stars 49 forks source link

Understand `provides` in pinned crate #1693

Open reznikmm opened 3 months ago

reznikmm commented 3 months ago

Describe the bug I want Alire to be able to pin a crate implementing a "virtual crate".

Use case: I have a crate (mybin) that depends on a "virtual crate" (coollib) and another crate (mylib) that provides that coollib in its alire.toml. I want to run alr pin mylib --use=<path>, but it fails.

To Reproduce

alr init --lib mylib
sed -i.bak -e '$aprovides=["coollib=1.0.0"]' mylib/alire.toml
alr init --bin mybin
sed -i.bak -e '$a[[depends-on]]\ncoollib = "^1.0"' mybin/alire.toml
alr -C mybin pin mylib --use=../mylib

ⓘ Synchronizing workspace...
Dependencies automatically updated as follows:

   New solution is incomplete.
   Missing:
   +❗      coollib ^1.0 (new,missing:unknown)

error: crate mismatch: expected coollib but found mylib at /tmp/bug/mylib

$ alr -C mybin with mylib --use=../mylib
error: crate mismatch: expected coollib but found mylib at /tmp/bug/mylib

Expected Behavior I want Alire to accept mylib as an implementation of coollib dependency.

alr version alr 2.0.1

mosteo commented 3 months ago

I see. My initial recollection is that the solver is not using such information from pinned crates. Incidentally, I'm reworking the solver to clean up a lot of mess there, so now would be a good time to fix this.