Difference between revisions of "Ghc-pkg"

From HaskellWiki
Jump to navigation Jump to 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 other 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.
   
  +
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.
Most used commands:
 
  +
ghc-pkg unregister
 
 
For more information, see the [http://www.haskell.org/ghc/docs/latest/html/users_guide/packages.html#package-management official documentation].
Remove a package from the GHC administration.
 
  +
 
== Most used commands ==
 
List all the registered packages:
 
ghc-pkg list
 
ghc-pkg list
 
Remove a package from the GHC administration:
List all the registered packages.
 
  +
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)
   
  +
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.
For more information, see the [http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/packages.html#package-management official documentation].
 

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.

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

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)

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.