无法安装 ghc-mod 由于无法安装 'happy'?

Cannot install ghc-mod due to 'happy' cannot be installed?

在 Mac OS X 上,我无法安装 ghc-mod,因为无法安装名为 'happy' 的依赖项:

bash> cabal install ghc-mod                                                                                           
Resolving dependencies...
Configuring haskell-src-exts-1.17.1...
Failed to install haskell-src-exts-1.17.1
Build log ( /Users/meng/.cabal/logs/haskell-src-exts-1.17.1.log ):
Configuring haskell-src-exts-1.17.1...
setup-Simple-Cabal-1.22.5.0-x86_64-osx-ghc-7.10.3: The program 'happy' version
>=1.19 is required but it could not be found.
cabal: Error: some packages failed to install:
ghc-mod-5.5.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.31 depends on haskell-src-exts-1.17.1 which failed to install.

有什么想法吗?

您的系统中似乎没有安装程序 happy,因此依赖它的软件包 haskell-src-exts-1.17.1(ghc-mod 的依赖项的依赖项)无法安装安装。

今天的常识,尤其是对于初学者来说,是不要使用工具 cabal-install,而是使用 stack 来获得您需要的一切。包括安装 ghc 本身。下载堆栈后,我想你所要做的就是 运行 stack install ghc-mod 安装 ghc-mod.

出于某种原因,cabal 不安装可执行依赖项,但您可以通过手动安装来解决这个问题。

cabal install happy

然后继续原来的安装。


这个问题通常也不会因堆栈而消失,但解决方案类似

stack install happy

然后继续安装。