Open gridbugs opened 1 year ago
I am not sure this is the right approach to this problem, as if I read #385 correctly the issue is more that the opam-0install-solver doesn't show the actual error that caused the issue. We already inject the a constraint that packages are supposed to build with dune, adding another way to enforce this makes it seem more like patching around weirdness of the solver.
To me it seems more sensible to fix the solver to actually output the expected error message (and from there we can better highlight the reason in a nicer error message, but if the solver doesn't actually display the reason and we're reimplementing parts of the solver that's quite bad). This has the added advantage of making it a better solver for all the current and potential future users of the solver.
I totally agree that the right thing to do is to fix this behaviour of the solver. I intended this change to be a quick and dirty workaround to improve opam-monorepo's UX while we spend more time improving the UX of the solver. I'm not sure yet whether the behavior in https://github.com/tarides/opam-monorepo/issues/385 is a bug in the solver or whether its API doesn't have a way to express that the "packages must build with dune" constraint is more important than other constraints.
The question is whether we expect to fix this behavior of the solver soon and if not what is the cost of adding this workaround in the meantime. This "fix" would have saved me a bunch of time while working on monorepo benchmarking as I would frequently generate a monorepo containing packages that didn't build with dune but the error messages didn't say which packages were causing the problem or even that the problem was related to dune at all so I resorted to binary searching.
This is a workaround for https://github.com/tarides/opam-monorepo/issues/385. The error message displayed when a some cases. This adds a check that direct dependencies all have available versions which build with dune before running the solver.
To demonstrate the problem, here's an opam file with one package that doesn't build with dune (ansicolor) and ocaml with a version constraint:
Prior to this change, running
opam monorepo lock
gives the error:...which is misleading because it doesn't mention anything about the fact that locking failed because ansicolor doesn't build with dune.
After this change the error is:
Read more at https://github.com/tarides/opam-monorepo/issues/385