[Haskell-cafe] cabal configure && cabal build && cabal install

Albert Y. C. Lai trebla at vex.net
Mon Nov 26 00:09:26 CET 2012

Among many programmers, and/or users who manually unpack source tarball 
before installing, this idiom is very common:

cabal configure
cabal build
cabal install

This idiom is an urban legend, i.e., a popular error.

"cabal install" re-does the "configure" and the "build" steps, among 
other things. That it has not caused trouble for you so far is only because:

1. "configure" has been idempotent, so far
2. the 2nd "build" has not caused duplicate work because ghc knows when 
not to re-compile

One day, you will run into a surprise, because you will add some flags 
to "configure", and then...

cabal configure --prefix=/nondefault --enable-shared
cabal build
cabal install

Whee! Your laborously entered flags are lost on deaf ears. You get the 
default prefix, and you get the default disable-shared. Why?

Because "cabal install" re-does the "configure" step, but this time, 
since you give no flags to "install", you give no flags to the 2nd 
"configure" either.

If you begin with "cabal configure", the correct idiom is:

cabal configure [flags]
cabal build
[cabal haddock, if you want]
cabal copy
cabal register

If you find it too long, why not just begin with:

cabal install [flags] [--enable-documentation, if you want]

More information about the Haskell-Cafe mailing list