Haskell项目依赖安装

时间:2014-10-08 19:58:38

标签: haskell cabal

我正在学习Haskell,并且在尝试运行任何不是简单的单文件教程文件(也就是真实项目)的项目时,我一直遇到依赖性问题。

我目前正在与之抗争的是我认为有趣且有趣的俄罗斯方块克隆。 Description of gamecode at github

我克隆了回购并运行了cabal install并得到了

Resolving dependencies...
cabal: Could not resolve dependencies:
trying: tetris-hs-0.1.0.0 (user goal)
next goal: base (dependency of tetris-hs-0.1.0.0)
rejecting: base-4.5.0.0/installed-40b... (conflict: tetris-hs => base>=4.6 && <4.8)
rejecting: base-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 installed instance)

我不知道这意味着什么,所以我开始寻找设置项目的步骤并登陆cabal user guide。开始使用runhaskell Setup.hs configure --user的变体,并获得了缺少依赖项的列表。当我尝试使用cabal install foo安装它们时,有时它会起作用,大部分时间我都会收到错误,例如,&#34;它已经安装了&#34; to&#34;没有名为&#39; Foo&#39;&#34;的包裹。一个有趣的是我安装netwire之后,我试图安装镜头,它回复说,&#34; cabal:重新安装可能会破坏以下软件包: netwire-5.0.0&#34;

如果我试图只运行runhaskell Main.hs它会说,&#34;找不到模块`Graphics.GLUtil&#39;&#34;如果我尝试安装Graphics.GLUtil,Graphics或GLUtil,它会说没有该名称的包。

我需要一本傻瓜书或其他东西。

编辑: 更新了ghc和cabal之后,我再次运行了cabal install并开始安装所有内容但是几分钟之后就撞到了一个凹凸并吐了出来:

cabal: Error: some packages failed to install:
FTGL-2.0 failed during the configure step. The exception was:
ExitFailure 1
GLFW-b-1.4.6 depends on bindings-GLFW-3.0.3.3 which failed to install.
GLUtil-0.8.2 depends on vector-0.10.11.0 which failed to install.
JuicyPixels-3.1.7.1 depends on vector-0.10.11.0 which failed to install.
adjunctions-4.2 depends on distributive-0.4.4 which failed to install.
bifunctors-4.1.1.1 depends on distributive-0.4.4 which failed to install.
bindings-GLFW-3.0.3.3 failed during the configure step. The exception was:
ExitFailure 1
comonad-4.2.2 depends on distributive-0.4.4 which failed to install.
distributive-0.4.4 failed during the building phase. The exception was:
ExitFailure 1
free-4.9 depends on distributive-0.4.4 which failed to install.
graphics-drawingcombinators-1.5 depends on FTGL-2.0 which failed to install.
lens-4.4.0.2 depends on vector-0.10.11.0 which failed to install.
linear-1.10.1.2 depends on vector-0.10.11.0 which failed to install.
profunctors-4.2.0.1 depends on distributive-0.4.4 which failed to install.
semigroupoids-4.2 depends on distributive-0.4.4 which failed to install.
tetris-hs-0.1.0.0 depends on vector-0.10.11.0 which failed to install.
vector-0.10.11.0 failed during the building phase. The exception was:
ExitFailure 1

当我尝试cabal install vector时:

[ 5 of 19] Compiling Data.Vector.Fusion.Stream.Monadic ( Data/Vector/Fusion/Stream/Monadic.hs,    dist/build/Data/Vector/Fusion/Stream/Monadic.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package primitive-0.5.3.0 ... <command line>: can't load .so/.DLL for: libHSprimitive-0.5.3.0.so (libHSprimitive-0.5.3.0.so: cannot open shared object file: No such file or directory)
cabal: Error: some packages failed to install:
vector-0.10.11.0 failed during the building phase. The exception was:
ExitFailure 1

2 个答案:

答案 0 :(得分:4)

这不是一个完整的解释,但我会指出问题并为你解释。

next goal: base (dependency of tetris-hs-0.1.0.0)
rejecting: base-4.5.0.0/installed-40b... (conflict: tetris-hs => base>=4.6 && <4.8)

next goal: base.“下一个目标”是愚蠢的绒毛; cabal正在大声思考。把它读作“试图满足这个包”。

rejecting: base-4.5.0.0/installed- ...这是您安装的版本。

conflict: tetris-hs => base>=4.6 ...版本4.5不起作用,因为tetris-hs需要&gt; = 4.6。

然后,消息的其余部分粗略地指出,您不能安装多个版本的base

不出所料,

base 基础包;除此之外,它还以各种方式连接到GHC本身。所以这一切归结为你的GHC版本对于包cabal文件中列出的版本而言太旧了。您可以安装最新的Haskell平台,也可以尝试编辑.cabal文件以允许旧版本 - 但如果由于其他原因导致编译失败,请不要感到惊讶。

编辑:阅读有关cabal沙箱的其他评论。沙箱与您的问题没有直接关系,但如果您理解并使用它们,您将来会避免一系列令人困惑的阴谋问题。

答案 1 :(得分:0)

加上CarstenKönig的评论:

  

hsenv(linux或MacOS)是一个工具(受Python的virtualenv启发)来创建孤立的Haskell环境。

这是我目前正在使用的那个我发现它非常好。我喜欢它的是能够继续使用标准命令

我还没有尝试过不同版本的GHC,但是在“高级用法”的页面上提到了

  

沙箱允许通过为每个包创建私有包环境来单独构建包。如果您熟悉Python的virtualenv或Ruby的RVM,那么这是一个Haskell模拟。

不确定您是否可以使用不同版本的ghc与cabal沙箱...

如果您使用的是Linux或MaxOS,那么直到最近我还有第三种选择,我不了解自己。如果你仔细阅读帖子,你会发现你可以 没有使用完整的NixOS。

  

Nix:安装软件的软件包管理器以及相关的编程语言。该项目可以与OS X一起安装在任何Linux发行版上。

     

Nixpkgs:定义如何安装GHC,Emacs等的软件的通用存储库。

     

在本文中,我们只关注Nix和Nixpkgs,因此即使您不想运行NixOS,也应该能够使用这些技术(但您完全应该运行NixOS)。