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.

@hvr
Copy link

hvr commented Nov 3, 2017

I tried with the latest released cabal-install, which is http://hackage.haskell.org/package/cabal-install-2.0.0.0 with a similarly setup project, and I deliberately made sure sndfile.h wouldn't be found:

$ /opt/cabal/2.0/bin/cabal --version
cabal-install version 2.0.0.0
compiled using version 2.0.0.2 of the Cabal library 

$ /opt/cabal/2.0/bin/cabal new-build
cabal: No targets given and there is no package in the current directory. Use
the target 'all' for all packages in the project or specify packages or
components by name or location. See 'cabal build --help' for more details on
target options.

$ /opt/cabal/2.0/bin/cabal new-build all
Resolving dependencies...
In order, the following will be built (use -v for more details):
 - hsndfile-0.8.0 (lib:hsndfile) (requires build)
 - text-short-0.1.1 (lib) (first run)
 - uhttpc-0.1.1.0 (lib) (first run)
 - uhttpc-0.1.1.0 (exe:uhttpc-bench) (first run)
Configuring hsndfile-0.8.0 (all, legacy fallback)...
Configuring library for text-short-0.1.1..
Preprocessing library for text-short-0.1.1..
Building library for text-short-0.1.1..
Building hsndfile-0.8.0 (all, legacy fallback)...
[1 of 3] Compiling Data.Text.Short.Internal ( src/Data/Text/Short/Internal.hs, /tmp/f/dist-newstyle/build/x86_64-linux/ghc-8.2.1/text-short-0.1.1/build/Data/Text/Short/Internal.o )
[2 of 3] Compiling Data.Text.Short  ( src/Data/Text/Short.hs, /tmp/f/dist-newstyle/build/x86_64-linux/ghc-8.2.1/text-short-0.1.1/build/Data/Text/Short.o )
[3 of 3] Compiling Data.Text.Short.Unsafe ( src/Data/Text/Short/Unsafe.hs, /tmp/f/dist-newstyle/build/x86_64-linux/ghc-8.2.1/text-short-0.1.1/build/Data/Text/Short/Unsafe.o )

Failed to build hsndfile-0.8.0.
Build log (
/home/hvr/.cabal/logs/ghc-8.2.1/hsndfile-0.8.0-1bbc97a43d9998801ca4db0d41b6e189a833176b74f5ca5009773fdc5b7869ea.log
):
Configuring hsndfile-0.8.0...
Preprocessing library for hsndfile-0.8.0..
dist/build/Sound/File/Sndfile/Interface.chs.h:3:21: fatal error: sndfile.h: No such file or directory
compilation terminated.
c2hs: Error during preprocessing custom header file
cabal: Failed to build hsndfile-0.8.0 (which is required by exe:uhttpc-bench
from uhttpc-0.1.1.0). See the build log above for details.

Is that more in line with what you would have expected?

@23Skidoo
Copy link

23Skidoo commented Nov 3, 2017

@nkpart Can you please produce a small self-contained repro case and file a bug report? Also, is it possible that you're using the 1.24 branch?

@nkpart
Copy link
Author

nkpart commented Nov 4, 2017

@23Skidoo Definitely on the 1.24.x.x. hvr suggested that everything might be good in 2.0 land. I'll give that a go and update according. I was pretty sure I had cabal install cabal-install right before I started, but I think I might have picked something up from a freeze file.

@nkpart
Copy link
Author

nkpart commented Nov 5, 2017

~/work-app
∴ /Users/nkpart/.cabal/bin/cabal --version
cabal-install version 2.0.0.0
compiled using version 2.0.0.2 of the Cabal library
~/work-app
∴ /Users/nkpart/.cabal/bin/cabal new-build
cabal: No targets given and there is no package in the current directory. Use
the target 'all' for all packages in the project or specify packages or
components by name or location. See 'cabal build --help' for more details on
target options.
~/work-app
∴ cat cabal.project
packages: tools/work-common/
          tools/work-app/
~/work-app
∴

I get the same won't build all behaviour, but maybe that's expected because I'm not using HEAD.

@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