How to list files installed by a Haskell cabal package?

366 Views Asked by At

Is there a way to list files installed by a Haskell cabal package? In other words: is there a way to list files associated with a Haskell package?

For example, in Debian based systems, including Ubuntu, one can use dpkg -l to list all packages, and dpkg -L package_name to list files associated with a given package:

$ dpkg -L gzip
/.
/bin
/bin/gunzip
/bin/gzexe
/bin/gzip
/bin/uncompress
/bin/zcat
/bin/zcmp
/bin/zdiff
/bin/zegrep
/bin/zfgrep
/bin/zforce
/bin/zgrep
/bin/zless
/bin/zmore
/bin/znew
/usr
/usr/share
...

On Arch Linux, the same is achieved by pacman -Ql package_name:

$ pacman -Ql gzip
gzip /usr/
gzip /usr/bin/
gzip /usr/bin/gunzip
gzip /usr/bin/gzexe
gzip /usr/bin/gzip
gzip /usr/bin/uncompress
gzip /usr/bin/zcat
gzip /usr/bin/zcmp
gzip /usr/bin/zdiff
gzip /usr/bin/zegrep
gzip /usr/bin/zfgrep
gzip /usr/bin/zforce
gzip /usr/bin/zgrep
gzip /usr/bin/zless
gzip /usr/bin/zmore
gzip /usr/bin/znew
gzip /usr/share/
...

Finally, using Python's PIP, one can use pip show -f package_name to show files associated with package package_name. 1

Is there a way to do the above for packages installed through cabal using either cabal or ghc-pkg? I know I can list packages using ghc-pkg list or cabal list --installed, but not how to list the files associated with specific packages.

1

There are 1 best solutions below

0
On

You can use ghc-pkg describe <pkgname> to get a collection of directories under which the package's files have been installed. There are only a few things affected by a package installation that won't be mentioned by this:

  1. The GHC package database itself is modified. ghc-pkg list will show you the locations of the two standard databases.
  2. Executables installed by the package aren't known to GHC. You can use cabal info <pkgname> to get a list of executables.
  3. Your build tool (i.e. cabal-install or stack) likely keeps a cache of package metadata and sources; these are not really "installed" in any meaningful sense -- deleting them won't break anything -- but they are bits of the filesystem modified by the installation process. For cabal-install this cache defaults to ~/.cabal/packages; I don't know enough about stack to answer about that tool well.