Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why Cabal changed build plans on us? #10470

Open
brandonchinn178 opened this issue Oct 18, 2024 · 2 comments
Open

Why Cabal changed build plans on us? #10470

brandonchinn178 opened this issue Oct 18, 2024 · 2 comments

Comments

@brandonchinn178
Copy link
Collaborator

Copying post from https://discourse.haskell.org/t/debug-why-cabal-is-choosing-a-version/10547; cc @grayjay. --allow-newer=lrucache:containers fixes the issue, but how did this happen in the first place?


At commit a0b03f1b3ed7ee31b7ee19caaa58d88afa5eb9d1 in Fourmolu, in the web/site/ subdirectory, if I run cabal build --dry-run, it resolves to hakyll-3.2.0.10. If I specify --constraint='hakyll>4', it shows the version I expect, hakyll 4.16.2.2. I would expect Cabal to always choose the more recent version if it's possible, so why is it resolving to 3.2.0.10? And why did it just start doing so?

CI passed on this commit on Oct 13, 5p PST: https://github.com/fourmolu/fourmolu/actions/runs/11318705914/job/31473662650

But the same commit is getting a different build plan now. I can repro locally, but it's also happening in CI for other PRs.

@georgefst
Copy link

Well, the short answer to the question is "because the state of Hackage changed". This happens all the time.

Sometimes, there is a conflict between choosing the latest version one package and of another (in this case, hakyll and containers). In other words, if we take the set of valid build plans and partially order it such that "A > B" means "some package has a higher version in A than in B", then there are multiple local maxima. I'd hazard a guess that in the vast majority of solver invocations in the real world, there is a single global maximum, and thus behaviour is usually intuitive.

What I'd really love to see, is for cabal-install to recognise these awkward situations and somehow explain the differences between each plan to the user. Failing that, it would be great to have a section in the user's guide on the behaviour of the solver, particularly on how it decides between local maxima.

@geekosaur
Copy link
Collaborator

There is an upcoming change that does try to explain solver failures. Cabal doesn't keep around enough state to tell you why a solver plan changed, though; that would require an external tool to compare solver runs (possibly via comparing plan.json from different runs).

In the meantime, perhaps pinning the index state will get you back on track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants