Search code examples
ghccabalcabal-install

Cabal install ignores a package in build-depends and then requests for it


Using cabal I'm trying to install iserv-proxy, it's build depends on libiserv and I've installed it before. when I issue install command:

ghc/utils/iserv-proxy$ cabal install -flibrary -fproxy

it fails with:

src/Main.hs:53:1: error:
Could not load module `Remote.Message'
It is a member of the hidden package `libiserv-8.6.3'.
Perhaps you need to add `libiserv' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
   |
53 | import Remote.Message
   | ^^^^^^^^^^^^^^^^^^^^^

as the error says, the Remote.Message is an exposed-module in libiserv, but the libiserv exists in the build-depends of iserv-proxy.cabal file, as is in the 8.6.3 version of ghc:
(only I changed containers upper dependency from 0.6 to 0.7 which was making dependency conflict.)

iserv-proxy.cabal:

.
.
.
Executable iserv-proxy
Default-Language: Haskell2010
Main-Is: Main.hs
Hs-Source-Dirs: src 
Build-Depends: array      >= 0.5 && < 0.6,
               base       >= 4   && < 5,
               binary     >= 0.7 && < 0.9,
               bytestring >= 0.10 && < 0.11,
               containers >= 0.5 && < 0.7,
               deepseq    >= 1.4 && < 1.5,
               directory  >= 1.3 && < 1.4,
               network    >= 2.6,
               filepath   >= 1.4 && < 1.5,
               ghci       == 8.6.*,
               libiserv   == 8.6.*

cabal is aware of libiserv installation:

$ cabal list --installed libiserv
* libiserv
    Default available version: [ Not available from any configured repository ]
    Installed versions: 8.6.3
    License:  BSD-3-Clause

and build-depends, as it seems in verbose log of install (-v), you may find it here in a pastebin.

It's so weired, I'm fairly new to cabal and ghc so I might messed something up. When I look into ghc command in the above verbose log:

/opt/ghc/bin/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir dist/build/iserv-proxy/iserv-proxy-tmp -odir dist/build/iserv-proxy/iserv-proxy-tmp -hidir dist/build/iserv-proxy/iserv-proxy-tmp -stubdir dist/build/iserv-proxy/iserv-proxy-tmp -i -idist/build/iserv-proxy/iserv-proxy-tmp -isrc -idist/build/iserv-proxy/autogen -idist/build/global-autogen -Idist/build/iserv-proxy/autogen -Idist/build/global-autogen -Idist/build/iserv-proxy/iserv-proxy-tmp -optP-include -optPdist/build/iserv-proxy/autogen/cabal_macros.h -hide-all-packages -Wmissing-home-modules -package-db dist/package.conf.inplace -package-id array-0.5.3.0 -package-id base-4.12.0.0 -package-id binary-0.8.6.0 -package-id bytestring-0.10.8.2 -package-id containers-0.6.0.1 -package-id deepseq-1.4.4.0 -package-id directory-1.3.3.0 -package-id filepath-1.4.2.1 -package-id ghci-8.6.3 -package-id libiserv-8.6.3 -package-id network-2.8.0.0-AkCJm1aNSYz7ekXKYyI0pF -XHaskell2010 src/Main.hs

It miss any -I or -include to libiserv library, and interestingly libiserv installation doesn't have any .h file or include directory:

$ ls /root/.cabal/lib/x86_64-linux-ghc-8.6.3/libiserv-8.6.3-EjLBkFaay9bH1Xm2bkeUPB/
GHCi  Lib.dyn_hi  Lib.hi  Remote  libHSlibiserv-8.6.3-EjLBkFaay9bH1Xm2bkeUPB.a

my config:

$ cabal --version
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library 
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.3
ghc$ git log -1
Author: Ben Gamari <[email protected]>
Date:   Thu Dec 6 16:58:34 2018 -0500

    Release 8.6.3

My ghc-pkg check returns couple of warnings for haddock-html and haddock-interfaces documents missing. you may find full output here in an another pastebin

Update:

adding --ghc-options="-i../../libraries/libiserv/src/" to the install command solved my case, but it should not be like that, so I let this question open, looking for better solution.


Solution

  • Note that libiserv can be built with support for network, and without. By default it will build without. You need libiserv to be built with -fnetwork for it to expose Remote.Message.

    Thus you probably want something like:

    libiserv $ cabal install -fnetwork
    iserv-proxy $ cabal install -flibrary -fproxy