eddex
eddex

Reputation: 2172

Cabal install (Cabal cabal-install) fails due to missing zlib library

I want to install Cabal 3.4.0.0 on Ubuntu 20.04.

$ sudo apt install cabal-install
$ cabal --version
cabal-install version 2.4.0.0

$ sudo cabal update
$ sudo cabal install Cabal cabal-install
...
Starting     zlib-0.6.2.3
Failed to install zlib-0.6.2.3
Build log ( /root/.cabal/logs/ghc-8.6.5/zlib-0.6.2.3-93Wbo8gIIzI9bg4p2MsNUF.log ):
cabal: Entering directory '/tmp/cabal-tmp-126381/zlib-0.6.2.3'
Configuring zlib-0.6.2.3...
cabal: Missing dependency on a foreign library:
* Missing (or bad) header file: zlib.h
* Missing (or bad) C library: z
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
library 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.
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.
...
cabal: Error: some packages failed to install:
cabal-install-3.4.0.0-3glzV3hM64DLoOfz3dHKsn depends on cabal-install-3.4.0.0
which failed to install.
hackage-security-0.6.0.1-KiAyVYLxooJAP3ckeQHnBD depends on
hackage-security-0.6.0.1 which failed to install.
zlib-0.6.2.3-93Wbo8gIIzI9bg4p2MsNUF failed during the configure step. The
exception was:
ExitFailure 1

The error says:

This problem can usually be solved by installing the system package that provides this library (you may need the "-dev" version).

How can I install this package on Ubuntu 20.04?

Upvotes: 9

Views: 3038

Answers (2)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 477437

You aim to install the cabal-install package [Hackage]. This package has a dependency that here produces a problem: the zlib package [Hackage].

This zlib package is essentially a thin wrapper around the zlib C library [wikipedia]. As the error says however, you did not install the zlib library, or at least not its package where one can develop with the zlib library.

We can install this by installing the libghc-zlib-dev software package, for example with:

sudo apt-get install libghc-zlib-dev

If we inspect the package details on Debian, we see that essentially this is a package that will install the zlib1g-dev package, the package to develop software with the zlib library. We can thus decide to install libghc-zlib-dev, or zlib1g-dev with:

sudo apt-get install zlib1g-dev

Upvotes: 11

Iury Fukuda
Iury Fukuda

Reputation: 149

Nixos Users append pkgs.haskellPackages.zlib to environment.systemPackages

Upvotes: 2

Related Questions