Cabal无法安装依赖项,但如果直接询问,则可以安装它们 [英] Cabal fails to install dependencies, but can install them if asked directly

查看:74
本文介绍了Cabal无法安装依赖项,但如果直接询问,则可以安装它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到Cabal反复出现了一个非常奇怪的问题,这干扰了我获得可重复的Haskell构建的能力.我有一个带有沙箱的阴谋计划.如果我执行 cabal安装,则会出现以下形式的错误

I've seen a very strange recurring problem with Cabal that's interfering with my ability to get repeatable Haskell builds. I have a cabal project with a sandbox. If I do cabal install, I get errors of the form

Y在构建阶段失败.例外是:退出失败1X取决于安装失败的Y.

其中X是我的项目的直接依赖项,而Y是某些可传递的依赖项.但是,如果我只是输入 cabal install X ,那么它就可以了!

where X is a direct dependency of my project and Y is some transitive dependency. However, if I just type cabal install X, then it works!

这是一个特定的示例:我的项目取决于 interpolate 包.当我执行 cabal install --allow-newer 时,出现如下错误:

Here's a specific example: my project depends on the interpolate package. When I do cabal install --allow-newer, I get errors like this:

Resolving dependencies...
Configuring haskell-src-meta-0.6.0.9...
Building haskell-src-meta-0.6.0.9...
Preprocessing library haskell-src-meta-0.6.0.9...
[1 of 6] Compiling Language.Haskell.TH.Instances.Lift ( src/Language/Haskell/TH/Instances/Lift.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/TH/Instances/Lift.o )
[2 of 6] Compiling Language.Haskell.Meta.Syntax.Translate ( src/Language/Haskell/Meta/Syntax/Translate.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta/Syntax/Translate.o )
[3 of 6] Compiling Language.Haskell.Meta.Parse ( src/Language/Haskell/Meta/Parse.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta/Parse.o )
[4 of 6] Compiling Language.Haskell.Meta.Parse.Careful ( src/Language/Haskell/Meta/Parse/Careful.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta/Parse/Careful.o )
[5 of 6] Compiling Language.Haskell.Meta ( src/Language/Haskell/Meta.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta.o )
[6 of 6] Compiling Language.Haskell.Meta.Utils ( src/Language/Haskell/Meta/Utils.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta/Utils.o )

src/Language/Haskell/Meta/Utils.hs:67:1:
    Duplicate instance declarations:
      instance Typeable Q
        -- Defined at src/Language/Haskell/Meta/Utils.hs:67:1
      instance Typeable Q -- Defined in ‘Language.Haskell.TH.Instances’

src/Language/Haskell/Meta/Utils.hs:71:1:
    Duplicate instance declarations:
      instance Typeable QuasiQuoter
        -- Defined at src/Language/Haskell/Meta/Utils.hs:71:1
      instance Typeable QuasiQuoter
        -- Defined in ‘Language.Haskell.TH.Instances’
Failed to install haskell-src-meta-0.6.0.9

...

haskell-src-meta-0.6.0.9 failed during the building phase. The exception was:
ExitFailure 1
interpolate-0.1.0 depends on haskell-src-meta-0.6.0.9 which failed to install.

但是,如果我继续输入 cabal install interpolate-0.1.0 ,则安装成功,并且我可以继续安装我的项目.

However, if I proceed to type cabal install interpolate-0.1.0, the installation succeeds and I'm able to keep installing my project.

这令人沮丧,因为我必须手动"安装几个软件包,然后才能安装所有依赖项.原始安装失败并出现编译器错误的事实似乎表明,编译器的配置方式有所不同?

This is frustrating because I have to "manually" install several packages before I can get all my dependencies installed. The fact that the original installations fail with compiler errors seems to suggest that the compiler is configured differently somehow?

我正在使用GHC 7.8.3和cabal-install 1.22.4.0(Cabal库的1.22.3.0版).非常感谢您的帮助!

I'm using GHC 7.8.3 and cabal-install 1.22.4.0 (version 1.22.3.0 of the Cabal library). Many thanks for any help!

推荐答案

实际上, haskell-src-meta 的版本不是问题,而是依赖项的版本 th-孤儿.

Actually it's not a problem with the version of haskell-src-meta but rather with the version of its dependency th-orphans.

haskell-src-meta (版本0.6.0.8和0.6.0.9)具有上限 th-orphans< 0.12 .

haskell-src-meta (versions 0.6.0.8 and 0.6.0.9) has an upper bound th-orphans <0.12.

使用-allow-newer ,您告诉Cabal忽略版本上限,所以Cabal决定使用 th-orphans 版本0.12.0,因为它是较新的并且大概是更好的.但是,实际上,正如您所发现的, haskell-src-meta 确实不是使用 th-orphans 版本0.12.0构建的.

With --allow-newer you told Cabal to ignore version upper bounds, so Cabal decided to use th-orphans version 0.12.0, since it's newer and presumably better. But, in fact, haskell-src-meta really does not build with th-orphans version 0.12.0, as you found out.

不受限制地使用-allow-newer 通常会遇到这种问题.最好使用-allow-newer = base,containers,... 指定要忽略其上限的软件包,尽管在某些情况下这样做可能很繁琐.

Unrestricted use of --allow-newer is likely to run into this kind of problem in general. It's better to specify the packages whose upper bounds you want to ignore with --allow-newer=base,containers,..., though in some cases doing so can be rather tedious.

在问题的第一句话中,您提到了可重复的构建.如果这是您想要的,那么除了简单地记录所有直接和间接依赖项所需的确切版本之外,别无他法.

In the first sentence of your question you mentioned repeatable builds. If that is what you want, there is no substitute for simply recording the exact versions that you want of all of your direct and indirect dependencies.

这篇关于Cabal无法安装依赖项,但如果直接询问,则可以安装它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆