When installing a package with cabal-install, it will also indirectly install all the dependencies. Given a certain package in my .cabal/packages
folder that I didn't directly install, is there a way to find what other package(s) it was a dependency of?
Is there a way to find why cabal installed a certain package?
558 Views Asked by hugomg At
2
There are 2 best solutions below
0

I found cabal-db to be helpful. For example, you can run
cabal-db revdeps semigroupoids
and it will tell you
zippers: semigroupoids (>=4 && <5)
wl-pprint-extras: semigroupoids (>=3 && <5)
vector-instances: semigroupoids (>=3)
validation: semigroupoids (>=4.0)
transformers-abort: semigroupoids (>=1.2)
these: semigroupoids (>=1.0 && <4.1)
etc...
I found this command somewhere (can't remember where now) and use it regularly to produce a dependency graph of my installed packages:
Note that it's actually
~/.ghc
which contains the installed package information, rather than~/.cabal
.You can also use:
which will print a list of packages which would break if you uninstalled this package, which is effectively what you are looking for:
Update
Using
dot -Tsvg > pkgs.svg
in the above command also allows you to use text searches (if you open the file in a browser, for example).Also, the cab utility is very useful for showing dependencies and reverse dependencies, amongst other things.
For stack users
stack dot --external
can be used from your project directory in place of the aboveghc-pkg dot
.