Personal tools

Ghc-pkg

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
 
(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.)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
The command ghc-pkg can be used to handle [[GHC]] packages.
+
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.
   
Most used commands:
+
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.
ghc-pkg unregister
+
Remove a package from the GHC administration.
+
For more information, see the [http://www.haskell.org/ghc/docs/latest/html/users_guide/packages.html#package-management official documentation].
  +
  +
== Most used commands ==
  +
List all the registered packages:
 
ghc-pkg list
 
ghc-pkg list
List all the registered packages.
+
Remove a package from the GHC administration:
  +
ghc-pkg unregister <packageName | packageName-version>
  +
Check for broken packages (see [http://www.haskell.org/ghc/docs/latest/html/users_guide/packages.html#package-ids documentation on broken packages])
  +
ghc-pkg check
  +
  +
== 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.
  +
  +
== 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)
   
For more information, see the [http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/packages.html#package-management official documentation].
+
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.

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.

[edit] 1 Most used commands

List all the registered packages:

 ghc-pkg list

Remove a package from the GHC administration:

 ghc-pkg unregister <packageName | packageName-version>

Check for broken packages (see documentation on broken packages)

 ghc-pkg check

[edit] 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.

[edit] 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.