<div dir="ltr">Hello,<div><br></div><div>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.</div><div><br></div><div>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").</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>I hope this helps,</div><div>-Iavor</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 15, 2019 at 3:01 PM Simon Peyton Jones via ghc-devs <<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-GB">
<div class="gmail-m_-4734454596412187589WordSection1">
<p class="MsoNormal">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?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The instructions here <a href="https://wiki.haskell.org/Cabal-Install" target="_blank">
https://wiki.haskell.org/Cabal-Install</a> just say “cabal install hspec” which is what I tried. Those instructions are pointed to from here
<a href="https://wiki.haskell.org/Cabal/How_to_install_a_Cabal_package" target="_blank">https://wiki.haskell.org/Cabal/How_to_install_a_Cabal_package</a>, which in turn are pointed to from the main Cabal home page
<a href="https://www.haskell.org/cabal/" target="_blank">https://www.haskell.org/cabal/</a>.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I must be missing something.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Simon<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Brandon Allbery <<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>>
<br>
<b>Sent:</b> 15 April 2019 22:54<br>
<b>To:</b> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>
<b>Cc:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: Cabal woes<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
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). <u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
On Mon, Apr 15, 2019 at 5:47 PM Simon Peyton Jones via ghc-devs <<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">I’m trying to install ‘hspec’ on my WSL (Windows subsystem for Linux) system.<u></u><u></u></p>
<p class="MsoNormal">But I fail; see below.<u></u><u></u></p>
<p class="MsoNormal">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.
<u></u><u></u></p>
<p class="MsoNormal">Alas, cabal then crashes outright, which should never happen.<u></u><u></u></p>
<p class="MsoNormal">So I’m stuck. What should I do?<u></u><u></u></p>
<p class="MsoNormal">Thanks<u></u><u></u></p>
<p class="MsoNormal">Simon<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">simonpj@MSRC-9870733:~$ cabal --version<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">cabal-install version 3.0.0.0<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">compiled using version 3.0.0.0 of the Cabal library
<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">simonpj@MSRC-9870733:~$ cabal install hspec<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">Resolving dependencies...<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">Up to date<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">Warning: You asked to install executables, but there are no executables in<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">target: hspec. Perhaps you want to use --lib to install libraries instead.<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">simonpj@MSRC-9870733:~$ cabal install --lib hspec<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">Resolving dependencies...<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">Up to date<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">Distribution/Simple/GHC.hs:1959:5-56: Irrefutable pattern failed for pattern Just ghcPkgProg<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code"> <u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">simonpj@MSRC-9870733:~$ which ghc<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">/opt/ghc/bin/ghc<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">simonpj@MSRC-9870733:~$ which ghc-pkg<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">/opt/ghc/bin/ghc-pkg<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code">simonpj@MSRC-9870733:~$<u></u><u></u></p>
<p class="gmail-m_-4734454596412187589gmail-m-1866220934865054569code"> <u></u><u></u></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.haskell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fghc-devs&data=02%7C01%7Csimonpj%40microsoft.com%7C49de1a60a36e4a04bbe208d6c1ecdac9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636909620364700618&sdata=dMUKGqIICFPisw%2Feskzb98WxcG9kfNFMOkZfd9fB7YU%3D&reserved=0" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">brandon s allbery kf8nh<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>