我想用Control.Monad.Except
模块,但结果发现我有一个过时的 mtl 包(它导致了导入错误 - 我有一个过时的模块Control.Monad.Error
)。所以我做了
sudo cabal install mtl
并且安装了2.2.2版本。但是,现在我安装了两个版本,2.1.2 和 2.2.2,仍然导致导入错误。我按照指示操作here https://stackoverflow.com/a/10587933/2266261 and did
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
outputs
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
让他们及时了解新版本。 Cabal-install 应该能够自动执行此操作,如果在您的项目文件夹中包含yourproject.cabal
文件,你做
$ cabal install --dependencies-only
正如丹尼尔所说,可能还需要添加--reinstall
,即如果 Cabal-install 没有正确捕获依赖项更改,并且需要手动勾选以重建它们。如果它认为重新安装本身可能会破坏其他软件包,--force-reinstalls
可能也需要。
避免依赖地狱的另一种方法是使用新的 Nix 风格命令 https://www.haskell.org/cabal/users-guide/nix-local-build-overview.html,重新安装时不会破坏任何东西。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)