Difference between revisions of "Cabal-Install"

From HaskellWiki
Jump to navigation Jump to search
(Added subsections in the Usage section and options to set in the config file; added remark about Haskell Platform including cabal-install)
(Added the subsection Error reporting)
Line 2: Line 2:
 
by automating the fetching, configuration, compilation and installation of Haskell libraries and programs.
 
by automating the fetching, configuration, compilation and installation of Haskell libraries and programs.
 
Those packages must be prepared using [[Cabal]] and should be present at [http://hackage.haskell.org/ Hackage].
 
Those packages must be prepared using [[Cabal]] and should be present at [http://hackage.haskell.org/ Hackage].
  +
   
 
== Usage ==
 
== Usage ==
Line 20: Line 21:
 
Occasionally you need to update the list of available packages:
 
Occasionally you need to update the list of available packages:
 
cabal update
 
cabal update
  +
   
 
=== The cabal-install configuration file ===
 
=== The cabal-install configuration file ===
Line 32: Line 34:
 
</haskell>
 
</haskell>
 
 
  +
 
==== Things to put in the config file ====
 
==== Things to put in the config file ====
 
To turn on --global by default:
 
To turn on --global by default:
Line 43: Line 46:
   
 
If you have the [[Haskell Platform]] installed, you already have cabal-install; no further action needed.
 
If you have the [[Haskell Platform]] installed, you already have cabal-install; no further action needed.
  +
   
 
=== Windows ===
 
=== Windows ===
Line 50: Line 54:
   
 
You must put the <code>cabal.exe</code> in a directory that is on your <code>%PATH%</code>, for example <code>C:\Program Files\Haskell\bin</code>.
 
You must put the <code>cabal.exe</code> in a directory that is on your <code>%PATH%</code>, for example <code>C:\Program Files\Haskell\bin</code>.
  +
   
 
=== Unix ===
 
=== Unix ===
Line 71: Line 76:
   
 
By default the cabal tool will install programs in <code>~/.cabal/bin</code>. If you decided not to put this directory on your <code>$PATH</code> then you can get cabal to symlink binaries into another directory, eg <code>~/bin</code>. To use this feature edit <code>~/.cabal/config</code> and see the <code>symlink-bindir field</code>. Note that the <code>~/.cabal/config</code> file is not created until you run a cabal command for the first time, eg <code>cabal update</code>.
 
By default the cabal tool will install programs in <code>~/.cabal/bin</code>. If you decided not to put this directory on your <code>$PATH</code> then you can get cabal to symlink binaries into another directory, eg <code>~/bin</code>. To use this feature edit <code>~/.cabal/config</code> and see the <code>symlink-bindir field</code>. Note that the <code>~/.cabal/config</code> file is not created until you run a cabal command for the first time, eg <code>cabal update</code>.
  +
   
 
=== Linux on Intel ===
 
=== Linux on Intel ===
   
 
There are also [http://code.haskell.org/~thielema/cabal/ unofficial binaries] for Intel-Linux.
 
There are also [http://code.haskell.org/~thielema/cabal/ unofficial binaries] for Intel-Linux.
  +
  +
  +
== Error reporting ==
  +
  +
Errors in cabal-install can be reported at
  +
[http://hackage.haskell.org/trac/hackage/ the Hackage Wiki and Bug Tracker]
  +
   
 
== See also ==
 
== See also ==

Revision as of 21:06, 18 August 2010

The cabal-install package provides the cabal command-line tool which simplifies the process of managing Haskell software by automating the fetching, configuration, compilation and installation of Haskell libraries and programs. Those packages must be prepared using Cabal and should be present at Hackage.


Usage

Installing a package

Once you have the tool installed, installing other packages is easy. To install Cabal packages from Hackage use:

 cabal install foo

Other common variations:

 cabal install                     Package in the current directory
 cabal install foo                 Package from the hackage server
 cabal install foo-1.0             Specific version of a package
 cabal install 'foo < 2'           Constrained package version
 cabal install foo bar baz         Several packages at once
 cabal install foo --dry-run       Show what would be installed

Occasionally you need to update the list of available packages:

 cabal update


The cabal-install configuration file

You can edit the cabal configuration file to set defaults:

 ~/.cabal/config (for *nix based systems)

For Windows there are different locations for different versions of Windows (just to make things easy). To get the directory cabal actually uses, paste this in ghci and press Enter:

 
:m System.Directory
getAppUserDataDirectory "cabal"


Things to put in the config file

To turn on --global by default:

 user-install: False

The root-cmd configuration parameter can be used to automatically run cabal-install with root privileges on *nix based systems, when needed:

 root-cmd: sudo


Installation

If you have the Haskell Platform installed, you already have cabal-install; no further action needed.


Windows

Get a pre-built cabal.exe from:

 http://www.haskell.org/cabal/download.html

You must put the cabal.exe in a directory that is on your %PATH%, for example C:\Program Files\Haskell\bin.


Unix

Download the latest cabal-install tarball from:

 http://www.haskell.org/cabal/download.html

It includes a shell script bootstrap.sh that you can run to download and install the other dependencies.

Note this assumes you have the zlib C library and its header files installed. Those header files are usually in a native system package like zlib-devel (On debian-based systems it is zlib1g-dev). You should also have the Haskell packages parsec and network installed. If you installed GHC via your native system package manager then you may also need to use it to install these two packages. (On debian-based systems they are called libghc6-parsec-dev and libghc6-network-dev.)

 tar -zxf cabal-install-0.6.2.tar.gz 
 cd cabal-install-0.6.2
 ./bootstrap.sh

If this completes successfully you will have the cabal binary in ~/.cabal/bin. You should either add this directory to your $PATH or copy the cabal program to some location that is on your $PATH, eg ~/bin.

to get the current list of package from hackage you should now run:

 cabal update

By default the cabal tool will install programs in ~/.cabal/bin. If you decided not to put this directory on your $PATH then you can get cabal to symlink binaries into another directory, eg ~/bin. To use this feature edit ~/.cabal/config and see the symlink-bindir field. Note that the ~/.cabal/config file is not created until you run a cabal command for the first time, eg cabal update.


Linux on Intel

There are also unofficial binaries for Intel-Linux.


Error reporting

Errors in cabal-install can be reported at the Hackage Wiki and Bug Tracker


See also