Cabal woes

Simon Peyton Jones simonpj at
Mon Apr 15 22:56:26 UTC 2019

That’s a tremendously helpful summary, thank you Iavor.  And Michail’s summary was also very helpful.

Most of this is doubtless well-known to habitual cabal users, but it might be useful to explain the user model, in a way that covers these points, somewhere close to the Cabal home page.


From: Iavor Diatchki <iavor.diatchki at>
Sent: 15 April 2019 23:39
To: Simon Peyton Jones <simonpj at>
Cc: Brandon Allbery <allbery.b at>; ghc-devs at
Subject: Re: Cabal woes


in case it is useful, here is how I think about what's happening with cabal.   At present, `cabal-install` supports two different modes of operation: the old style (aka `v1`) and the new style (aka `v2`) and---at least for me---the two require a slightly different mental model of what is going on.

In the old model, there is a user package database, and users would use "cabal install" to install libraries their manually (e.g., using `cabal-install`).   Later, when building various artifacts cabal would prefer using the packages installed in the user's database.  This database supported having multiple versions of a package, but NOT multiple builds of the same version of a package (e.g., against different dependencies).  As a result, builds would sometimes fail, because the dependencies of packages would clash with each other (the unfortunate "cabal hell").

With the new model, there is still a "user" level location where libraries are installed, but it is not really directly manipulated by the user---rather it acts as more of a "cache" containing all versions of all libraries every built and---crucially---it supports having multiple builds of the same version of a package against different dependencies.   When users build an artifact using the new style (aka "v2"), cabal automatically checks if a suitable version of the library is already built in its cache, and if not it adds it there.

The important difference between the two (at least in my mind) is that with the new style, you never just install a library on its own.  Rather, you install it as a part of a project, so Cabal can compute which version it should install so that you get a version compatible with the rest of the project.   Since in this model you never really install libraries directly, the `install` command defaults to installing executables, which is what the first error is trying to say.

So, if you want to try out `hspec` with the `v2` style of Cabal, you'd just add it as a dependencies in the `cabal` file of your project, and then use `cabal v2-build` to build the project, without having to install it manually first.

I hope this helps,

On Mon, Apr 15, 2019 at 3:01 PM Simon Peyton Jones via ghc-devs <ghc-devs at<mailto:ghc-devs at>> wrote:
Thanks.  But alas I have no clue about whether I want a v1-install or a v2-install, nor how to achieve them if I knew what they were.  I just want to install ‘hspec’ so that I can use it when compiling a program.  How would I do that?

The instructions here<> just say “cabal install hspec” which is what I tried.  Those instructions are pointed to from here<>, which in turn are pointed to from the main Cabal home page<>.

I must be missing something.


From: Brandon Allbery <allbery.b at<mailto:allbery.b at>>
Sent: 15 April 2019 22:54
To: Simon Peyton Jones <simonpj at<mailto:simonpj at>>
Cc: ghc-devs at<mailto:ghc-devs at>
Subject: Re: Cabal woes

I think you wanted v1-install to install a library into the user package database, since your cabal is 3.x and the v2-* commands are now the default (that is, you did what used to be cabal new-install or cabal v2-install).

On Mon, Apr 15, 2019 at 5:47 PM Simon Peyton Jones via ghc-devs <ghc-devs at<mailto:ghc-devs at>> wrote:
I’m trying to install ‘hspec’ on my WSL (Windows subsystem for Linux) system.
But I fail; see below.
For some reason cabal complains about installing a library.  (That seems peculiar – isn’t that what cabal is for?)  But it helpfully suggests adding –lib.
Alas, cabal then crashes outright, which should never happen.
So I’m stuck.  What should I do?

simonpj at MSRC-9870733:~$ cabal --version

cabal-install version

compiled using version of the Cabal library

simonpj at MSRC-9870733:~$ cabal install hspec

Resolving dependencies...

Up to date

Warning: You asked to install executables, but there are no executables in

target: hspec. Perhaps you want to use --lib to install libraries instead.

simonpj at MSRC-9870733:~$ cabal install --lib hspec

Resolving dependencies...

Up to date

Distribution/Simple/GHC.hs:1959:5-56: Irrefutable pattern failed for pattern Just ghcPkgProg

simonpj at MSRC-9870733:~$ which ghc


simonpj at MSRC-9870733:~$ which ghc-pkg


simonpj at MSRC-9870733:~$

ghc-devs mailing list
ghc-devs at<mailto:ghc-devs at><>

brandon s allbery kf8nh
allbery.b at<mailto:allbery.b at>
ghc-devs mailing list
ghc-devs at<mailto:ghc-devs at><>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list