How do you debug your dune/dune-packages/*.opam?

In the project I’m working on, since my latest rebase, I get a

Missing dependency:
    - deps-of-foo → bin_prot < v0.12.0
    no matching version

which is fairly weird, because I’ve explicitly specified bin_prot = 0.16.0.

I will eventually find out what’s wrong, by bissecting stuff, but I’m sure that there is a better way to do this.

Is there a way to ask opam or dune to tell me which path led to requiring bin_prot < v0.12.0?

opam tree might do what you’re asking? I’m not sure how it works when there are conflicts

1 Like

without seeing the source, my guess would be that you forgot the initial v prefix, common for janestreet packages due to a version scheme rename some years ago.
It should be bin_prot = v0.16.0 (the initial v is not optional)

1 Like

Sadly, according to opam tree, nothing expects < 0.12.0.

I’m sure that the constraint comes from somewhere, though :slight_smile:

Thanks, this seems to be the issue at hand!

But I’d be interested in a more general answer on how to debug such issues in the future.

that’s a good question but i don’t think there are any satisfying answers at the moment sadly.
The code in charge of explaining why the dependency solver can’t find a solution is quite complex and was already improved quite a bit in ocaml/opam#6106 as part of opam 2.3.0, but it is still pretty confusing in most cases due to the way it currently works.

In your case for example, the reason you get v0.12.0 instead of 0.16.0 is because version numbers are reconstructed using existing packages instead of taken directly from the package definition (for internal historical reasons), so since 0.16.0 doesn’t exist the code will take the closest existing version which is v0.12.0 (since 0.16.0 < v0.12.0 < v0.16.0).

I’m hoping to be able to fix that in the future but i haven’t had the time to work on it since (contributions are always welcome if anyone is interested though)

Happy to contribute.

In this specific case, a warning would have been useful, for instance. Would that be an acceptable PR?

I’m not exactly sure what you have in mind, but sure go for it, we can discuss of the specifics in the PR