(Changed the lay-out)
(Someone told me that this page is where they land after having trouble with cabal, so I added bit more information on how to handle packaging problems.)
Latest revision as of 10:08, 30 April 2013
The command ghc-pkg can be used to handle GHC packages. It is used both internally by other tools and by GHC users. This means that it contains many commands that are often not needed by an average user.
This tool is perhaps most often used for uninstalling unneeded packages and those packages that are incompatible with packages that the user wants to install. It is also used for checking which packages are installed or have been broken by installs of other packages.
For more information, see the official documentation.
 1 Most used commands
List all the registered packages:
Remove a package from the GHC administration:
ghc-pkg unregister <packageName | packageName-version>
Check for broken packages (see documentation on broken packages)
 2 Notice about ghc-pkg usage
Although ghc-pkg is useful tool, it shouldn't be needed for daily development. Invoking cabal install with all the required packages often solves the same problems.
 3 Short usage example
An example where ghc-pkg can be used is when some unneccessary package obstructs installation of a desired package:
~/Code/CV$ cabal install --dry-run Resolving dependencies... In order, the following would be installed: CV-0.3.7 (reinstall) cabal: The following packages are likely to be broken by the reinstalls: DynLine-0.1.0.0 Use --force-reinstalls if you want to install anyway.
Here, CV cannot be installed because DynLine would get broken. Since we don't want DynLine, we can remove it:
~/Code/CV$ ghc-pkg unregister DynLine-0.1.0.0 ~/Code/CV$ cabal install --dry-run Resolving dependencies... In order, the following would be installed: CV-0.3.7 (reinstall)
Now, if we want both DynLine and CV to be installed, we would tell cabal that it is ok to install both:
~/Code/CV$ cabal install --dry-run . ../DynLine/ Resolving dependencies... In order, the following would be installed: CV-0.3.7 (reinstall) DynLine-0.1.0.0 (reinstall)
Here, the "." points to current directory containing CV package. It is important to tell cabal to install both at the same time. Otherwise cabal would try to use the already installed packages, which is impossible due to dependencies.