cabal-install 不考虑我安装的变形金刚版本

My installed transformers version is not considered by cabal-install

我是 Haskell 阴谋集团的新手,我正在努力让 yesod 发挥作用。

我的cabal版本是cabal-install version 1.20.0.3 使用版本 1.20.0.2 的 Cabal 库

这是我安装 alex 时发生的事情:

$ cabal install alex
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: alex-3.1.4 (user goal)
next goal: QuickCheck (dependency of alex-3.1.4)
rejecting: QuickCheck-2.8.1, 2.8 (global constraint requires ==2.7.6)
trying: QuickCheck-2.7.6
next goal: transformers (dependency of QuickCheck-2.7.6)
rejecting: transformers-0.4.3.0, 0.4.2.0, 0.4.1.0, 0.3.0.0, 0.2.2.1, 0.2.2.0,
0.2.1.0, 0.2.0.0, 0.1.4.0, 0.1.3.0, 0.1.1.0, 0.1.0.1, 0.1.0.0, 0.0.1.0,
0.0.0.0, 0.4.0.0 (global constraint requires installed instance)
Dependency tree exhaustively searched.

第二次尝试:

$ cabal install alex happy yesod-bin --allow-newer
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: alex-3.1.4 (user goal)
trying: QuickCheck-2.7.6/installed-1a8... (dependency of alex-3.1.4)
trying: tf-random-0.5/installed-ef3... (dependency of
QuickCheck-2.7.6/installed-1a8...)
next goal: primitive (dependency of tf-random-0.5/installed-ef3...)
rejecting: primitive-0.5.0.1/installed-8e5... (global constraint requires
==0.6)
rejecting: primitive-0.6 (conflict: tf-random =>
primitive==0.5.0.1/installed-8e5...)
rejecting: primitive-0.5.4.0, 0.5.3.0, 0.5.2.1, 0.5.1.0, 0.5.0.1, 0.5, 0.4.1,
0.4.0.1, 0.4, 0.3.1, 0.3, 0.2.1, 0.2, 0.1 (global constraint requires ==0.6)
Dependency tree exhaustively searched.

安装 alex 需要做什么?

一个相关的问题是:

@kosmikus 对该问题的评论是:

So the Stackage LTS config file contains the constraint transformers installed, meaning that only an already present version of transformers can be used. This is reasonable, because GHC ships with a specific version of transformers. For ghc-7.8, this is transformers-0.3.0.0. For some reason, this installed version is not considered by cabal-install. Your partial log doesn't contain sufficient info to see why.

如何修复我的 Stackage LTS 配置文件?它在 Ubuntu 上的什么位置?

问题的原因是我的GHC太旧了。我下载了更新的版本并解决了问题。

尝试失败(且错误)

您的当前目录中应该有一个 cabal.config 文件。使用任何文本编辑器打开它并搜索 transformers installed 字符串。

找到后,将其替换为 transformers ==0.4.3.0 或您喜欢的任何其他版本。

这是一个糟糕的解决方案,因为,正如 dfeurer 所写:

transformers sits very far down in the package dependency structure. I believe it depends only on base; I imagine a large majority of packages on Hackage depend, directly or indirectly, on it. If you upgrade transformers, practically every dependency in the system will go screwy, which is the opposite of what you're going for if you're using Stackage.


Sibi 的清洁解决方案

按原样使用堆栈包。如果您有一些全局包导致问题,请删除它们并专门使用 stackage。对每个项目使用沙箱也是一个好主意。

试试这个 cabal install alex --allow-newer