更新MTL后找不到模块`Control.Monad.State` [英] Could not find module `Control.Monad.State` after updating mtl
问题描述
我想使用 Control.Monad.Except
模块,但事实证明我有一个过时的mtl包(它导致导入错误-我有一个过时的模块 Control.Monad.错误
).所以我做了
I wanted to use the Control.Monad.Except
module, but it turned out I had an outdated mtl package (It caused an import error - I had an obsolete module Control.Monad.Error
). So I did
sudo cabal install mtl
它安装了2.2.2版本.但是,现在我安装了两个版本,即2.1.2和2.2.2,仍然导致导入错误.我按照此处的说明进行操作,
And it installed the 2.2.2 version. However, now I had two versions installed, 2.1.2 and 2.2.2 which still caused an import error. I followed instructions here and did
sudo ghc-pkg unregister --force mtl-2.1.2
删除旧版本.但是现在我得到一个错误:
to remove the old version. But now I get an error:
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检查
输出
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
我现在该怎么办?
推荐答案
您需要重新安装所有依赖 mtl
的软件包,以使它们与新版本保持最新.如果在带有 yourproject.cabal
文件的项目文件夹中执行了Cabing安装,那么Cabal-install应该能够自动执行此操作
You need to reinstall all the packages that depend on mtl
to get them up to date with the new version. Cabal-install should be able to do that automatically if, in your project folder with the yourproject.cabal
file, you do
$ cabal install --dependencies-only
正如丹尼尔所说,可能还需要添加-reinstall
,即,如果Cabal-install没有正确地适应依赖项更改,并且需要手动打勾以重建它们.如果它认为重新安装本身可能会破坏其他软件包,则可能还需要-force-reinstalls
.
As Daniel remarks, it may also be necessary to add --reinstall
, namely if Cabal-install hasn't properly caught on to the dependency changes and needs to be manually ticked onto rebuilding them. If it thinks the reinstalls themselves might break yet other packages, --force-reinstalls
may be needed too.
避免依赖地狱的另一种方法是使用新的Nix样式命令,重新安装时不会破坏任何内容.
An alternative that avoids dependency hell is using the new Nix-style commands, which never break anything when reinstalling.
这篇关于更新MTL后找不到模块`Control.Monad.State`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!