4

我在使用 cabal 时遇到了麻烦,不确定是由于缺乏理解还是心智模式错误,但事情一直很艰难。

目前我只是想让 ghc-mod 为我的 vim 插件工作。它通常工作一两天,然后似乎无缘无故地开始失败并出现错误,我收到的错误似乎不时发生变化,现在我得到了这个:

$ ghc-mod check Main.hs
ghc-mod: /Users/chris/.stack/snapshots/x86_64-osx/lts-6.15/7.10.3/pkgdb/package.cache: 
GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!)

关于如何解决这类问题的任何想法?我已经尝试再次安装它,但我明白了(我认为我的阴谋集团包都搞砸了,但不知道如何修复它):

$ cabal install ghc-mod
Resolving dependencies...
Downloading haskell-src-exts-1.17.1...
Configuring haskell-src-exts-1.17.1...
Failed to install haskell-src-exts-1.17.1
Build log ( /Users/chris/.cabal/logs/haskell-src-exts-1.17.1.log ):
cabal: Entering directory '/var/folders/6l/rdh2g5wn41s8vxchngkt02_c0000gn/T/cabal-tmp-45583/haskell-src-exts-1.17.1'
Configuring haskell-src-exts-1.17.1...
cabal: The program 'happy' version >=1.19 is required but it could not be
found.
cabal: Leaving directory '/var/folders/6l/rdh2g5wn41s8vxchngkt02_c0000gn/T/cabal-tmp-45583/haskell-src-exts-1.17.1'
cabal: Error: some packages failed to install:
ghc-mod-5.6.0.0 depends on haskell-src-exts-1.17.1 which failed to install.
haskell-src-exts-1.17.1 failed during the configure step. The exception was:
ExitFailure 1
hlint-1.9.35 depends on haskell-src-exts-1.17.1 which failed to install.

编辑:看了一会儿,又试了一次,现在我遇到了这个错误,有点厌倦了阴谋集团一直在改变主意:

$ ghc-mod check Main.hs
[1 of 5] Compiling CabalHelper.Common ( CabalHelper/Common.hs, /Users/chris/.ghc-mod/cabal-helper/CabalHelper/Common.o  )
[2 of 5] Compiling CabalHelper.Licenses ( CabalHelper/Licenses.hs, /Users/chris/.ghc-mod/cabal-helper/CabalHelper/Licenses.o  )

CabalHelper/Licenses.hs:53:18: error:
Ambiguous occurrence ‘lookupInstalledPackageId’
It could refer to either ‘Distribution.Simple.PackageIndex.lookupInstalledPackageId’,
imported from ‘Distribution.Simple.PackageIndex’ at CabalHelper/Licenses.hs:24:1-39
or ‘CabalHelper.Licenses.lookupInstalledPackageId’,
defined at CabalHelper/Licenses.hs:38:1

CabalHelper/Licenses.hs:74:10: error:
Ambiguous occurrence ‘lookupInstalledPackageId’
It could refer to either ‘Distribution.Simple.PackageIndex.lookupInstalledPackageId’,
imported from ‘Distribution.Simple.PackageIndex’ at CabalHelper/Licenses.hs:24:1-39
or ‘CabalHelper.Licenses.lookupInstalledPackageId’,
defined at CabalHelper/Licenses.hs:38:1
ghc-mod: readCreateProcess: /Users/chris/.stack/snapshots/x86_64-osx/lts-6.15/7.10.3/libexec/cabal-helper-wrapper "--with-ghc=/usr/local/bin/ghc" "--with-ghc-pkg=/usr/local/bin/ghc-pkg" "--with-cabal=cabal" "/Users/chris/dev/formatter" "/Users/chris/dev/formatter/.stack-work/dist/x86_64-osx/Cabal-1.24.0.0" "package-db-stack" "entrypoints" "source-dirs" "ghc-options" "ghc-src-options" "ghc-pkg-options" "ghc-merged-pkg-options" "ghc-lang-options" "licenses" "flags" "config-flags" "non-default-config-flags" "compiler-version" (exit 1): failed
4

1 回答 1

0

此错误是由于我的本地堆栈 ghc 版本和全局 ghc-mod ghc 版本不匹配引起的,我将堆栈项目中的 ghc 版本更新为最新并且一切正常。

于 2016-11-10T00:27:18.573 回答