tarides / opam-monorepo

Assemble dune workspaces to build your project and its dependencies as a whole
ISC License
130 stars 27 forks source link

opam monorepo depext vs opam install --depext-only #306

Closed hannesm closed 2 years ago

hannesm commented 2 years ago

I am wondering whether there is a difference between executing (on any lockfile) opam install --depext-only <file> and opam monorepo depext -l <file>. If the answer is yes, I'd be keen to know what the difference is.

Thanks a lot.

NathanReb commented 2 years ago

There is indeed, even though a subtle one!

The main difference is that with opam install, you will have an extra, unecessary solver run as opam will try to resolve the dependencies to install all transitive depexts of the opam file, even though they were compiled in the depext field by opam-monorepo. Unfortunately there is no way at the moment to tell either opam install --depext-only or opam depext to only install the depexts defined in the file.

As a consequence, opam install could fail in some cases:

  1. If the upstream metadata have changed and the solution described by the lock file cannot be found by the solver anymore
  2. Because of the pin-depends field in lock files and potential differences between upstream metadata and archive/git repos opam files, the solver could fail to find a solution.

2 can be easily worked around using opam install --ignore-pin-depends --depext-only <file>.

opam monorepo depext will simply resolve the depexts formula based on the opam variables currently defined and install the resulting system packages.

hannesm commented 2 years ago

Thanks for your quick and detailed explanation.