Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out why cabal chooses an old version of a library?

Say I'm running cabal install A B C D ... --dry-run in a fresh install of GHC (I just updated a new version). I see some of the dependencies it wants to pull in are not the latest versions of those packages, e.g:

utf8-string-0.3.8 (latest: 1)
cairo-0.12.5.3 (latest: 0.13.1.0)
glib-0.12.5.4 (latest: 0.13.1.0)
gio-0.12.5.3 (latest: 0.13.1.0)
pango-0.12.5.3 (latest: 0.13.1.0)
gtk-0.12.5.7 (latest: 0.13.6)

Now, this is often perfectly normal (especially recently after a new version of GHC is released). I don't care about the particular packages listed here. But when I see this I like to do a quick check of why cabal was unable to use the most recent version of those packages. Often it means that one of the things I asked it to install hasn't been updated and is still depending on old versions, and sometimes I don't actually need to install that and would rather not have it dragging the version of other packages.

Sometimes these "not the latest versions" are very old, which usually means something I'm asking for is totally incompatible with recent stuff, but has found a solution using ancient versions with very loose constraints.

What I'd like to do is find out which of the packages I'm installing are causing this. Usually I can see something like "oh, those are a bunch of graphics packages, it's probably xmonad or taffybar that's the reason", and I go check the latest version of xmonad and taffybar on hackage to see what their constraints on these packages are. But often the "obvious culprits" like this actually don't have relevant constraints on these dependencies, which means the problem is some other package which is a dependency of what I asked for and also has a dependency on the packages that I'm not getting the latest version of, where that package isn't compatible with the latest version of the package cabal is reporting. Finding such a package (and why what I actually care about is depending on it) can be a tricky task!

Are there any tools or tricks that can help answer this question? I'm aware of the dependency tools at http://packdeps.haskellers.com/, which is useful, but doesn't seem to do exactly what I want; I can use the reverse dependency list to start at the packages which cabal wants an out of date version of and work forward until I find something I recognise, or I can query individual packages in the dependency monitor one at a time and work backwards until I find one of the not-latest packages. But it seems like the question I'm asking should be more directly answerable.

like image 800
Ben Avatar asked Oct 31 '22 07:10

Ben


1 Answers

One way to do this is to run cabal with -v3. This will give you a lot of debug output, but it will also show you the dead ends that the solver explored.

If you are only interested in a few packages then another possibility is to add --constraint='thePackage >= 1.2.3', where 1.2.3 is the minimum version that you expect thePackage to have. Given this, cabal will generate an error that explains why this constraint is unsatisfiable.

like image 62
bennofs Avatar answered Nov 15 '22 06:11

bennofs