在 16.04 上安装 cabal 很麻烦

在 16.04 上安装 cabal 很麻烦

最近又切换回了 Ubuntu 16.04,在让 cabal 工作时遇到了前所未有的麻烦。Cabal 1.22 当前已安装并“正在工作”...

我尝试安装一个我编写的测试包,但是它依赖于 base>=4.10,而 cabal 1.22 显然无法访问:

cabal update
cabal install base

Resolving dependencies...
All the requested packages are already installed:
base-4.9.1.0
Use --reinstall if you want to reinstall anyway.

cabal install base-4.10

Resolving dependencies...
cabal: Could not resolve dependencies:
next goal: base (user goal)
rejecting: base-4.10.0.0, 4.9.1.0/installed-4.9..., 4.9.1.0, 4.9.0.0, 4.8.2.0,
4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1, 4.6.0.0, 4.5.1.0,
4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0,
4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global constraint requires ==4.10)
Dependency tree exhaustively searched.

因此我尝试安装最新版本的 cabal:

Resolving dependencies...
Configuring zlib-0.6.2...
Failed to install zlib-0.6.2
Build log ( /home/ebanflo/.cabal/logs/zlib-0.6.2.log ):
Configuring zlib-0.6.2...
setup-Simple-Cabal-2.2.0.1-x86_64-linux-ghc-8.0.2: 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-2.2.0.0 depends on zlib-0.6.2 which failed to install.
hackage-security-0.5.3.0 depends on zlib-0.6.2 which failed to install.
zlib-0.6.2 failed during the configure step. The exception was:
ExitFailure 1

我尝试安装zlib并收到相同的错误消息。

我很想上传一个具有较低依赖性的软件包的新版本来看看它是否可以工作,但是还没有这样做,因为这是一个愚蠢的解决方案,因为我仍然无法下载具有这些无法访问的依赖性的软件包。

更新:

我尝试zlib1g-devapt存储库安装:

sudo apt install zlib1g-dev

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 zlib1g-dev : Depends: zlib1g (= 1:1.2.8.dfsg-2ubuntu4) but 1:1.2.8.dfsg-2ubuntu4.1 is to be installed
E: Unable to correct problems, you have held broken packages.

因此我尝试安装非开发版本:

sudo apt install zlib1g

Reading package lists... Done
Building dependency tree       
Reading state information... Done
zlib1g is already the newest version (1:1.2.8.dfsg-2ubuntu4.1).
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.

我尝试安装一些东西1.2.8.dfsg-2ubuntu4,但我想我不知道正确的语法。我还尝试了purgezlib1g autoremove,但这两个命令都出现了以下错误消息:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 crda : Depends: libssl1.0.0 (>= 1.0.0) but it is not going to be installed
 libical1a : Depends: tzdata but it is not going to be installed
 mount : PreDepends: libblkid1 (>= 2.17.2) but it is not going to be installed
         PreDepends: libmount1 (>= 2.25) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

接下来我将尝试直接从 cabal 源包安装评论中提到的 Haskell zlib。

下载、提取、运行ghc Setup并尝试运行./Setup configure,但收到​​以下错误消息:

Configuring zlib-0.6.2...
Setup: 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.

嗯,应该没问题,我有一些版本zlib1g已安装,或者我以为是。运行后dpkg -L zlib我发现没有二进制文件zlib。我完全迷路了。

答案1

这里是 Haskell 的初学者。

sudo apt install libghc-zlib-dev在同样的症状但不同的情况下(使用堆栈并包括 zlib 或任何其他依赖于 package.yaml 中的 zlib 的包,然后尝试调用stack build)对我来说起了作用。

我希望这能解决你的问题。

相关内容