Difference between revisions of "Cabal-Install"

From HaskellWiki
Jump to navigation Jump to search
(download binaries)
(Significantly rewrite the page and bring it up-to-date)
Line 1: Line 1:
The <code>cabal-install</code> package provides the <code>cabal</code> command-line program
+
The <code>cabal-install</code> package provides the <code>cabal</code> command-line tool which simplifies the process of managing Haskell software
which simplifies the process of managing Haskell software
 
 
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/ HackageDB].
+
Those packages must be prepared using [[Cabal]] and should be present at [http://hackage.haskell.org/ Hackage].
   
  +
== Usage ==
Once you have running cabal-install installation of further packages is just one simple shell call like
 
cabal install new-package
 
   
  +
Once you have the tool installed then installing other packages easy. To install Cabal packages from Hackage use:
Also uploading a new package to HackageDB is as simple as
 
 
cabal install foo
cabal upload ./dist/new-package-1.0.tar.gz
 
   
  +
Other common variations:
But before you can do that, you have to complete the:
 
  +
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
  +
  +
You can edit the cabal configuration file to set defaults:
  +
~/.cabal/config
  +
  +
Or on Windows the config file lives at:
  +
C:\Documents and Settings\username\Application Data\cabal\config
   
 
== Installation ==
 
== Installation ==
   
  +
=== Windows ===
You must download the following tarballs and you must [[Cabal/How to install a Cabal package|build and install]] them manually.
 
  +
  +
Get a pre-built <code>cabal.exe</code> from:
 
http://www.haskell.org/cabal/download.html
  +
  +
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 ===
   
Cabal-install package itself:
+
Download the latest cabal-install tarball from:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cabal-install
+
http://www.haskell.org/cabal/download.html
   
  +
It includes a shell script <code>bootstrap.sh</code> that you can run to download and install the other dependencies.
Dependencies that aren't in core:
 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HTTP
 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/zlib
 
   
  +
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 <code>zlib-devel</code> (On debian-based systems it is <code>zlib1g-dev</code>). You should also have the Haskell packages <code>parsec</code> and <code>network</code> 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 <code>libghc6-parsec-dev</code> and <code>libghc6-network-dev</code>.)
Note the last one assumes you have zlib the C library and its header files installed.
 
Those header files are usually in a package like zlib-devel. On Windows, cabal-install bundles the Zlib library, so you won't need to obtain it yourself.
 
   
  +
tar -zxf cabal-install-0.6.2.tar.gz
If that succeeds, that's possibly the last time you ever installed a foreign Haskell package manually!
 
  +
cd cabal-install-0.6.2
  +
./bootstrap.sh
   
  +
If this completes successfully you will have the cabal binary in <code>~/.cabal/bin</code>. You should either add this directory to your <code>$PATH</code> or copy the cabal program to some location that is on your <code>$PATH</code>, eg <code>~/bin</code>.
== Download binaries ==
 
   
  +
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>.
Some hints from Haskell-Cafe on [http://www.haskell.org/pipermail/haskell-cafe/2009-January/053835.html runghc Setup.hs doitall]
 
* [http://haskell.org/~duncan/cabal/cabal.exe Windows]
 
* [http://users.informatik.uni-halle.de/~thielema/Haskell/cabal Linux on Intel]
 
   
 
== See also ==
 
== See also ==
   
* [http://hackage.haskell.org/trac/hackage/wiki/CabalInstall Cabal-install] page on Hackage-Trac
+
* [http://hackage.haskell.org/trac/hackage/wiki/CabalInstall cabal-install] page on the Cabal/Hackage development site.
   
 
[[Category:Tools]]
 
[[Category:Tools]]

Revision as of 12:10, 6 March 2009

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

Once you have the tool installed then installing other packages 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

You can edit the cabal configuration file to set defaults:

 ~/.cabal/config

Or on Windows the config file lives at:

 C:\Documents and Settings\username\Application Data\cabal\config

Installation

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.

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.

See also