我想使用Control.Monad.Except
模块,但事实证明我有一个过时的mtl包(它导致导入错误 - 我有一个过时的模块Control.Monad.Error
)。所以我做了
sudo cabal install mtl
它安装了2.2.2版本。但是,现在我安装了两个版本,2.1.2和2.2.2仍然导致导入错误。我按照说明here做了
sudo ghc-pkg unregister --force mtl-2.1.2
删除旧版本。但现在我收到了一个错误:
Could not find module `Control.Monad.State'
It is a member of the hidden package `monads-tf-0.1.0.2'.
Use -v to see a list of the files searched for.
ghc-pkg check
输出
There are problems in package HTTP-4000.2.17:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
There are problems in package fgl-5.5.0.1:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
There are problems in package cgi-3001.1.8.5:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
There are problems in package parsec-3.1.3:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
There are problems in package regex-base-0.93.2:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
HTTP-4000.2.17
fgl-5.5.0.1
cgi-3001.1.8.5
parsec-3.1.3
regex-base-0.93.2
network-2.4.1.2
regex-compat-0.95.1
regex-posix-0.95.2
我现在该怎么办?
答案 0 :(得分:2)
您需要重新安装依赖mtl
的所有软件包,以使其与新版本保持同步。如果您在包含yourproject.cabal
文件的项目文件夹中执行
$ cabal install --dependencies-only
正如Daniel所说,可能还需要添加--reinstall
,即如果Cabal-install没有正确地接收到依赖项更改,则需要手动勾选重建它们。如果它认为重新安装本身可能会破坏其他软件包,则可能也需要--force-reinstalls
。
避免依赖地狱的另一种方法是使用new Nix-style commands,它在重新安装时不会破坏任何内容。