Using a remote vcs dependency (pkg-b) this unexpectedly fails:
$ git clone https://github.com/hvr/cabal-bugs
$ cd cabal-bugs/issue-5469
$ cabal new-build all
Cloning into '/tmp/cabal-bugs/issue-5469/dist-newstyle/src/cabal-bugs-7607c4ae10cdb862'...
remote: Counting objects: 62, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 62 (delta 2), reused 16 (delta 1), pack-reused 44
Unpacking objects: 100% (62/62), done.
Checking connectivity... done.
Note: checking out 'b23f3277270b2066163fabde41a08be1261bf9eb'.
HEAD is now at b23f327... Add repro-case for haskell/cabal#5469
Resolving dependencies...
Build profile: -w ghc-8.2.2 -O1
In order, the following will be built (use -v for more details):
- pkg-a-0 (lib) (first run)
- pkg-b-0 (exe:b) (first run)
Configuring library for pkg-a-0..
Preprocessing library for pkg-a-0..
Building library for pkg-a-0..
[1 of 2] Compiling Paths_pkg_a ( /tmp/cabal-bugs/issue-5469/dist-newstyle/build/x86_64-linux/ghc-8.2.2/pkg-a-0/build/autogen/Paths_pkg_a.hs, /tmp/cabal-bugs/issue-5469/dist-newstyle/build/x86_64-linux/ghc-8.2.2/pkg-a-0/build/Paths_pkg_a.o )
[2 of 2] Compiling A ( src/A.hs, /tmp/cabal-bugs/issue-5469/dist-newstyle/build/x86_64-linux/ghc-8.2.2/pkg-a-0/build/A.o )
Configuring executable 'b' for pkg-b-0..
Preprocessing executable 'b' for pkg-b-0..
Building executable 'b' for pkg-b-0..
[1 of 1] Compiling Main ( Main.hs, /tmp/cabal-bugs/issue-5469/dist-newstyle/build/x86_64-linux/ghc-8.2.2/pkg-b-0/x/b/build/b/b-tmp/Main.o )
filename = "/home/hvr/.cabal/share/x86_64-linux-ghc-8.2.2/pkg-a-0/datafile.txt"
Main.hs:8:9: error:
• Exception when trying to run compile-time code:
/home/hvr/.cabal/share/x86_64-linux-ghc-8.2.2/pkg-a-0/datafile.txt: openFile: does not exist (No such file or directory)
Code: embedDataFileTxt
• In the untyped splice: $(embedDataFileTxt)
|
8 | s = $(embedDataFileTxt)
| ^^^^^^^^^^^^^^^^^^^
However, for a simple folder-based local package (using the cabal.ok.project file) this works just fine:
$ cabal --proj=cabal.ok.project new-build all
Resolving dependencies...
Build profile: -w ghc-8.2.2 -O1
In order, the following will be built (use -v for more details):
- pkg-a-0 (lib) (first run)
- pkg-b-0 (exe:b) (first run)
Configuring library for pkg-a-0..
Preprocessing library for pkg-a-0..
Building library for pkg-a-0..
[1 of 2] Compiling Paths_pkg_a ( /tmp/cabal-bugs/issue-5469/dist-newstyle/build/x86_64-linux/ghc-8.2.2/pkg-a-0/build/autogen/Paths_pkg_a.hs, /tmp/cabal-bugs/issue-5469/dist-newstyle/build/x86_64-linux/ghc-8.2.2/pkg-a-0/build/Paths_pkg_a.o )
[2 of 2] Compiling A ( src/A.hs, /tmp/cabal-bugs/issue-5469/dist-newstyle/build/x86_64-linux/ghc-8.2.2/pkg-a-0/build/A.o )
Configuring executable 'b' for pkg-b-0..
Preprocessing executable 'b' for pkg-b-0..
Building executable 'b' for pkg-b-0..
[1 of 1] Compiling Main ( Main.hs, /tmp/cabal-bugs/issue-5469/dist-newstyle/build/x86_64-linux/ghc-8.2.2/pkg-b-0/x/b/build/b/b-tmp/Main.o )
filename = "/tmp/cabal-bugs/issue-5469/pkg-a/datadir/datafile.txt"
Linking /tmp/cabal-bugs/issue-5469/dist-newstyle/build/x86_64-linux/ghc-8.2.2/pkg-b-0/x/b/build/b/b ...
So the problem is that in the VCS codepaths, the pkg_a_datadir env-var isn't set, wheres in the 2nd case the pkg_a_datadir env-var is set properly.
(cc @edsko: jfyi, this is the very bug we're experiencing w/ the cardano-sl repo)
Most helpful comment
Just noticed this TODO:
https://github.com/haskell/cabal/blob/c13767a0fc0b80da75e77f9616b8536f8f5147ac/cabal-install/Distribution/Client/ProjectPlanning/Types.hs#L389-L408