I recently upgraded to Cabal 3.2 (and GHC 8.10) and I am running into some major issues that make some of my project non-buildable anymore...
Thorough description of the problem
Here is a minimal (not) working configuration that fails every time:
I start off with a clean Cabal configuration (by deleting
~/.cabal
); the reason for that will appear later in the post. I runcabal update
to recreate the.cabal
directory and to ensure Cabal is working.I create a project (let's call it
test1
) usingcabal init
. This is a library project with one exposed module (conveniently namedTest1
) that exports some dummy functionfoo
. I runcabal build
, thencabal install --lib
; everything is running smooth, so far so good.Just to be sure, I leave the project directory and fire up GHCi. I type in
:m Test1
to load the module I created earlier, and it works! I can type infoo ...
and see my function executed. Also, I list the content of~/.cabal/store/ghc-8.10.xxx
and see that thetest1-xxx
directory is there.I then create a new project,
test2
, still usingcabal init
. This time, I configure it to be an executable, and I addtest1
as a dependency (using thebuild-depends
field). But this time when I runcabal build
, I run into some issue:
~/projects/haskell/test2> cabal build
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: test2-0.1.0.0 (user goal)
[__1] unknown package: test1 (dependency of test2)
[__1] fail (backjumping, conflict set: test1, test2)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: test2, test1
It seems to me like package test1
cannot be found, however I can access it from GHCi (and GHC for that matters) and it is present in ~/.cabal/store
...
But unfortunately there is more.
- I create a third project,
test3
. This is a library, and it depends on nothing else thanbase
(so in particular it does not depend ontest1
). The lib exposes one module,Test3
, with one function exported,bar
. I runcabal build
, no problem here. But when I want to installtest3
withcabal install --lib
I run into some errors:
~/projects/haskell/test3> cabal install --lib
Wrote tarball sdist to
/home/<user>/projects/haskell/test3/dist-newstyle/sdist/test3-0.1.0.0.tar.gz
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] unknown package: test1 (user goal)
[__0] fail (backjumping, conflict set: test1)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: test1
It seems that it cannot find test1
, although it has been installed correctly; may be this is a remnant of the failed build of test2
though...
Just to be sure, I fire up GHCi and type in
:m Test3
, but GHCi tells me that it cannot find moduleTest3
(and even suggests this is a typo and I was meaningTest1
), showing thattest3
indeed did not get installed, although it got successfully built...Okay there is one more quirk to this whole situation: I create once again a new project with
cabal init
, calledtest4
, which is an executable that (again) depends on nothing else thanbase
. I keep the defaultMain.hs
(that just prints "Hello, Haskell!"). I runcabal build
: no problem. Then I runcabal install
and... No problem either? I runtest4
in a random location and it fires up the executable, printing "Hello, Haskell!" in the terminal...And there is one last thing: I go to some random location and I run
cabal install xxx --lib
wherexxx
is a library package available on Hackage (for examplexml
) and:
~> cabal install xml --lib
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] unknown package: test1 (user goal)
[__0] fail (backjumping, conflict set: test1)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: test1
This is the reason why I need to nuke .cabal
regularly... Right now I seem to be in some kind of stale state where I cannot install any library anymore.
Technical configuration and notes
I am running Cabal 3.2.0.0 and GHC 8.10.0.20200123. I installed them from the hvr/ghc PPA, and I made sure there are no other versions of those tools anywhere on my computer.
Just as a note, I am running Ubuntu 18.04.4 LTS (with XFCE so XUbuntu to be exact). Everything else (seem to be like it) is up to date.
Last thing, regarding the *.cabal
files I use for building, they are pretty much the ones generated by cabal init
, except I switch executable xxx
for library
in the case of libraries, and I simply add a exposed-modules
field for exposing modules for the libraries (so Test1
for test1
and Test3
for test3
respectively). I also use build-depends
in test2
to make the project depend on test1
. Apart from that, they are pretty much left untouched.
Notes and thoughts
I must confess that I am new to Cabal 3; until last week I was using Cabal 1 (because I never bothered to update it; yes I know this is bad). With Cabal 1 I did not have any problem whatsoever, and I was perfectly able to install a package from local sources and depend on it in other projects...
I feel like I am doing something wrong; maybe am I not using the correct Cabal commands? I saw somewhere something about cabal new-build
and cabal new-install
but it does not seem to do anything more than cabal build
and cabal install
, at least in my case. I also wanted to investigate sandboxes but it seems that has disappeared since version 2 of Cabal.
There is also a slight possibility this is a Cabal bug, but I don't find any relevant issue on the bug tracker that may be related to my problem...
What do you think about this? What am I doing wrong? Do you see any alternative or possible fix?
Thanks a lot!