Skip to content

Instantly share code, notes, and snippets.

@nkpart
Last active January 20, 2019 04:35
Show Gist options
  • Save nkpart/d84e201af45a5f9379443f3ed0e34e01 to your computer and use it in GitHub Desktop.
Save nkpart/d84e201af45a5f9379443f3ed0e34e01 to your computer and use it in GitHub Desktop.
∴ cat cabal.project
packages: tools/work-common/
          tools/work-project/

I did the expected thing, and tried to build everything:

∴ cabal new-build
Up to date
∴

Nothing was built.

I read the docs here: http://cabal.readthedocs.io/en/latest/nix-local-build.html#developing-multiple-packages

Then, to build every component of every package, from the top-level directory, run the command: (Warning: cabal-install-1.24 does NOT have this behavior; you will need to upgrade to HEAD.)

Oh. As I'm using the latest released cabal, that does not work for me.

∴ cabal new-build work-project
In order, the following will be built (use -v for more details):
gtk2hs-buildtools-0.13.2.2
cairo-0.13.3.1
Chart-cairo-1.8.2
hsndfile-0.8.0
hsndfile-vector-0.5.2
zlib-0.6.1.2
streaming-commons-0.1.18
conduit-extra-1.1.17
conduit-combinators-1.1.1
work-project-0.1.0.0
Configuring hsndfile-0.8.0...
Configuring zlib-0.6.1.2...
Configuring gtk2hs-buildtools-0.13.2.2...
Building hsndfile-0.8.0...
∴

The process ended. Nothing had been built.

Let's try again with verbose on.

∴ cabal new-build work-project --verbose
In order, the following will be built:
gtk2hs-buildtools-0.13.2.2 (lib:gtk2hs-buildtools) (requires build)
cairo-0.13.3.1 (lib:cairo) (requires build)
Chart-cairo-1.8.2 (lib:Chart-cairo) (requires build)
hsndfile-0.8.0 (lib:hsndfile) (requires build)
hsndfile-vector-0.5.2 (lib:hsndfile-vector) (requires build)
zlib-0.6.1.2 (lib:zlib) (requires build)
streaming-commons-0.1.18 (lib:streaming-commons) (requires build)
conduit-extra-1.1.17 (lib:conduit-extra) (requires build)
conduit-combinators-1.1.1 (lib:conduit-combinators) (requires build)
work-project-0.1.0.0 (lib:work-project) (first run)

... [SNIP] ...

Building hsndfile-0.8.0...
/Users/nkpart/.local/bin/cabal act-as-setup --build-type=Simple -- build
--verbose=2 --builddir=dist
Redirecting build log to {handle:
/Users/nkpart/.cabal/logs/hsndfile-0.8.0.log}

∴

Again. Process ended.

∴ tail -n 5 /Users/nkpart/.cabal/logs/hsndfile-0.8.0.log
dist/build/Sound/File/Sndfile/Interface.chs.h:3:10: fatal error: 'sndfile.h' file not found
#include <sndfile.h>
         ^~~~~~~~~~~
1 error generated.
c2hs: Error during preprocessing custom header file

The error is legit, the lack of reporting is not.

Maybe things are better in cabal HEAD, but right now, cabal-latest might build my work projects, but won't report errors.

Therefore, at work, we need to use either a HEAD version of cabal, or a HEAD version of stack (as stack-released will not build cassava-0.5.1.0), to build our haskell code.

@nkpart
Copy link
Author

nkpart commented Nov 5, 2017

I ran:

∴ /Users/nkpart/.cabal/bin/cabal new-build all --extra-include-dirs=/usr/local/include --extra-lib-dirs=/usr/local/lib
Failed to build digest-0.0.1.2. The failure occurred during the configure
step.
Build log (
/Users/nkpart/.cabal/logs/ghc-8.0.2/digest-0.0.1.2-5d30d30d7d2e93c4245c1d2f590f03bf3515dc7425cc86e699c5f54e3ca962cf.log
):
Configuring digest-0.0.1.2...
cabal: Missing dependency on a foreign library:
* Missing (or bad) header file: zlib.h
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
∴ ls /usr/local/include/zlib.h
/usr/local/include/zlib.h

@nkpart
Copy link
Author

nkpart commented Nov 5, 2017

Following http://cabal.readthedocs.io/en/latest/nix-local-build.html#cfg-field-extra-include-dirs, I added that configuration to the cabal.project file, but I get the same error.

extra-lib-dirs: /usr/local/lib
extra-include-dirs: /usr/local/include

@hvr
Copy link

hvr commented Dec 20, 2017

The last one is a known issue; for now you have to be specific about which package ought to get those extra flags, i.e.

package zlib
  extra-lib-dirs: /usr/local/lib
  extra-include-dirs: /usr/local/include

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment