ghc-pkg(1)

πŸ“¦
version 9.12.2 Β· 2 versions
, in debian bookworm, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu jammy

πŸ’– ghc-pkg β€” GHC Haskell Cabal package manager πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about the <rainbow>package manager for GHC's Haskell Cabal packages. This is from the General Commands Manual, and it's genuinely iconic, no cap.


✨ SYNOPSIS ✨

ghc-pkg action [OPTION]...

πŸ¦‹ DESCRIPTION πŸ¦‹

So, a package is literally just a library of Haskell modules that the compiler knows about. The ghc-pkg tool is your girl for adding them to a package database or yeeting them out of one. By default? It messes with the system-wide package database. But if you want, you can also act on the user's local package database, or a whole other file you specify. Your call, main character.

To make a package available for ghc, you use ghc-pkg to register it. Unregistering it removes it from the database. And here's the tea: packages can also be hidden, which makes ghc ignore the package by default without uninstalling it. Then exposing a package makes a hidden package available again. On top of all that, ghc-pkg has a bunch of commands to query the package database. Versatile queen πŸ’….

Now, when a package name is required, you can name the package in full β€” version number and all (e.g. network-1.0) β€” or without the version number. Naming a package without the version number matches all versions of the package, and the specified action gets applied to all the matching packages. And if you want to be super clear that you're matching multiple packages, you can write a package specifier as pkg-*. Periodt.


πŸ‘‘ ACTIONS πŸ‘‘

  • register filename|- β€” Register the package using the specified installed package description.
  • update filename|- β€” Register the package, overwriting any other package with the same name.
  • unregister pkg-id β€” Unregister the specified package.
  • expose pkg-id β€” Expose the specified package.
  • hide pkg-id β€” Hide the specified package
  • list [pkg]... β€” List registered packages in the global database, and also the user database if --user is given. If a package name is given, all the registered versions will be listed in ascending order. Accepts the --simple-output flag.
  • dot β€” Generate a graph of the package dependencies in a form suitable for input for the graphviz tools. For example, to generate a PDF of the dependency graph:
dot  tred  dot -Tpdf >pkgs.pdf
  • find-module module β€” List registered packages exposing module module in the global database, and also the user database if --user is given. All the registered versions will be listed in ascending order. Accepts the --simple-output flag.
  • latest pkg-id β€” Prints the highest registered version of a package.
  • check β€” Check the consistency of package dependencies and list broken packages. Accepts the --simple-output flag.
  • describe pkg β€” Give the registered description for the specified package. The description is returned in precisely the syntax required by ghc-pkg register.
  • field pkg field β€” Extract the specified field of the package description for the specified package. Accepts comma-separated multiple fields.
  • dump β€” Dump the registered description for every package. This is like ghc-pkg describe '*', expect that it is intended to be used by tools that parse the results, rather than humans.
  • recache β€” Regenerate the package database cache. This command should only be necessary if you added a package to the database by dropping a file into the database directory manyally. By default, the global DB is recached; to recache a different DB use --user or --package-conf as appropriate.

🌸 OPTIONS 🌸

πŸŽ€ When asked to modify a database

When asked to modify a database (register, unregister, update, hide, expose, and also check), ghc-pkg modifies the global database by default. Specifying --user causes it to act on the user database, or --package-conf can be used to act on another database entirely. When multiple of these options are given, the rightmost one is used as the database to act upon. That's the rule, bestie.

Commands that query the package database (list, latest, describe, field) operate on the list of databases specified by the flags --user, --global, and --package-conf. If none of these flags are given, the default is --global --user.


  • --user β€” Use the current user's package database.
  • --global β€” Use the global package database.
  • -f FILE, --package-conf=FILE β€” Use the specified package config file.
  • --global-conf=FILE β€” Location of the global package config.
  • --force β€” Ignore missing dependencies, directories, and libraries.
  • --force-files β€” Ignore missing directories and libraries only.
  • -g, --auto-ghc-libs β€” Automatically build libs for GHCi (with register).
  • -?, --help β€” Display a help message and exit.
  • -V, --version β€” Output version information and exit.
  • --simple-output β€” Print output in easy-to-parse format for some commands.
  • --names-only β€” Only print package names, not versions; can only be used with list --simple-output.
  • --ignore-case β€” Ignore case for substring matching.

🌈 ENVIRONMENT VARIABLES 🌈

  • GHC_PACKAGE_PATH β€” The GHC_PACKAGE_PATH environment variable may be set to a :-separated list of files containing package databases. This list of package databases is used by ghc and ghc-pkg, with earlier databases in the list overriding later ones. This order was chosen to match the behaviour of the PATH environment variable; think of it as a list of package databases that are searched left-to-right for packages.

If GHC_PACKAGE_PATH ends in a separator, then the default user and system package databases are appended, in that order. e.g. to augment the usual set of packages with a database of your own, you could say:

export GHC_PACKAGE_PATH=$HOME/.my-ghc-packages.conf:

To check whether your GHC_PACKAGE_PATH setting is doing the right thing, ghc-pkg list will list all the databases in use, in the reverse order they are searched. Vibe check your env vars, fr fr.


πŸ“ FILES πŸ“

Both of these locations are changed for Debian. Upstream still keeps these under /usr. Some programs may refer to that, but look in /var instead. Noted. πŸ“

  • /var/lib/ghc/package.conf β€” Global package.conf file.
  • /var/lib/ghc/package.conf.d/ β€” Directory for library specific package.conf files. These are added to the global registry.

πŸ’œ SEE ALSO πŸ’œ

ghc(1), runghc(1), hugs(1).


🫢 AUTHOR 🫢

This manual page was written by Kari Pahula <kaol@debian.org>, for the Debian project (and may be used by others).


and that's the whole page, bestie πŸ’– this one's from 2010-01-27, part of the ghc-pkg(1) manual β€” go forth and manage those packages, you absolute icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from