我首先从https://www.haskell.org/platform/设置了Haskell,但是ghc-mod的沙箱存在问题,要对其进行更新,我需要更新的cabal和更新的ghc。或类似的东西。(https://stackoverflow.com/a/28049104/131227 ??)
因此,我删除了所有内容,并从http://ghcformacosx.github.io/安装。然后,建立新的沙箱时发生了一些奇怪的失败,是因为某些事情没有适当地依赖于快乐。(https://github.com/haskell-suite/haskell-src-exts/issues/14)
好。装高兴。现在尝试(再次)安装ghc-mod,而我却陷入了一片混乱。
我应该使用http://www.stackage.org/吗?
我见过有人提到ghc-pkg recache
或cabal install cabal-install
...我需要做那些事情吗?
混乱:
Resolving dependencies... Configuring ghc-mod-5.2.1.2... Building ghc-mod-5.2.1.2... Failed to install ghc-mod-5.2.1.2 Build log ( /Users/mark/.cabal/logs/ghc-mod-5.2.1.2.log ): Configuring ghc-mod-5.2.1.2... Building ghc-mod-5.2.1.2... Preprocessing library ghc-mod-5.2.1.2...
Language/Haskell/GhcMod/Convert.hs:1:51: Warning:
-XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS [ 1 of 38] Compiling Language.Haskell.GhcMod.Read ( Language/Haskell/GhcMod/Read.hs, dist/build/Language/Haskell/GhcMod/Read.o ) [ 2 of 38] Compiling Language.Haskell.GhcMod.Cabal21 ( Language/Haskell/GhcMod/Cabal21.hs, dist/build/Language/Haskell/GhcMod/Cabal21.o ) [ 3 of 38] Compiling Language.Haskell.GhcMod.Cabal18 ( Language/Haskell/GhcMod/Cabal18.hs, dist/build/Language/Haskell/GhcMod/Cabal18.o ) [ 4 of 38] Compiling Language.Haskell.GhcMod.Cabal16 ( Language/Haskell/GhcMod/Cabal16.hs, dist/build/Language/Haskell/GhcMod/Cabal16.o ) [ 5 of 38] Compiling Language.Haskell.GhcMod.GHCChoice ( Language/Haskell/GhcMod/GHCChoice.hs, dist/build/Language/Haskell/GhcMod/GHCChoice.o ) [ 6 of 38] Compiling Language.Haskell.GhcMod.Error ( Language/Haskell/GhcMod/Error.hs, dist/build/Language/Haskell/GhcMod/Error.o )
Language/Haskell/GhcMod/Error.hs:12:1: Warning:
Module ‘Control.Monad.Error’ is deprecated:
Use Control.Monad.Except instead
Language/Haskell/GhcMod/Error.hs:40:10: Warning:
In the use of type constructor or class ‘Error’
(imported from Control.Monad.Error, but defined in Control.Monad.Trans.Error):
Deprecated: "Use Control.Monad.Trans.Except instead"
Language/Haskell/GhcMod/Error.hs:40:10: Warning:
In the use of type constructor or class ‘Error’
(imported from Control.Monad.Error, but defined in Control.Monad.Trans.Error):
Deprecated: "Use Control.Monad.Trans.Except instead" [ 7 of 38] Compiling Language.Haskell.GhcMod.Utils ( Language/Haskell/GhcMod/Utils.hs, dist/build/Language/Haskell/GhcMod/Utils.o )
Language/Haskell/GhcMod/Utils.hs:15:1: Warning:
The import of ‘Control.Applicative’ is redundant
except perhaps to import instances from ‘Control.Applicative’
To import instances alone, use: import Control.Applicative()
Language/Haskell/GhcMod/Utils.hs:45:51: Warning:
In the use of ‘strMsg’
(imported from Language.Haskell.GhcMod.Error, but defined in Control.Monad.Trans.Error):
Deprecated: "Use Control.Monad.Trans.Except instead" [ 8 of 38] Compiling Language.Haskell.GhcMod.Types ( Language/Haskell/GhcMod/Types.hs, dist/build/Language/Haskell/GhcMod/Types.o ) [ 9 of 38] Compiling Language.Haskell.GhcMod.Gap ( Language/Haskell/GhcMod/Gap.hs, dist/build/Language/Haskell/GhcMod/Gap.o )
Language/Haskell/GhcMod/Gap.hs:256:18:
Not in scope: data constructor ‘ExposePackageId’
Perhaps you meant ‘ExposePackage’ (imported from DynFlags) cabal: Error: some packages failed to install: ghc-mod-5.2.1.2 failed during the building phase. The exception was: ExitFailure 1
应用可接受的答案(似乎已安装ghc-mod)后,运行gch-mod会给出以下信息:
> ghc-mod check x.hs
cabal-helper-wrapper: Installing a private copy of Cabal, this might take a
while but will only happen once per Cabal version.
If anything goes horribly wrong just delete this directory and try again:
/Users/mark/.ghc-mod/cabal-helper
If you want to avoid this automatic installation altogether install version
1.22.0.0 of Cabal manually (into your user or global package-db):
$ cabal install Cabal-1.22.0.0
...In order, the following would be installed:
filepath-1.3.0.1 (latest: 1.4.0.0) (new version)
directory-1.2.2.1 (new version)
process-1.2.3.0 (reinstall) changes: directory-1.2.2.0 -> 1.2.2.1,
filepath-1.4.0.0 -> 1.3.0.1
Cabal-1.22.0.0 (latest: 1.22.2.0) (new version)
cabal: The following packages are likely to be broken by the reinstalls:
ghc-7.10.1
Cabal-1.22.2.0
Use --force-reinstalls if you want to install anyway.
cabal-helper-wrapper: Installing Cabal version 1.22.0.0 failed.
nYou have two choices now:
- Either you install this version of Cabal in your globa/luser package-db
somehow
n- Or you can see if you can update your cabal-install to use a different
version of the Cabal library that we can build with:
$ cabal install cabal-install --constraint 'Cabal > 1.22.0.0'
nTo check the version cabal-install is currently using try:
$ cabal --version
ghc-mod: readCreateProcess: /Users/mark/.cabal/libexec/cabal-helper-wrapper "/Users/mark/work/haskell/ixberg/dist" "entrypoints" "source-dirs" "ghc-options" "ghc-src-options" "ghc-pkg-options" "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" (exit 1): failed
奇怪的是,它需要当前安装的Cabal版本:
> cabal --version
cabal-install version 1.22.0.0
using version 1.22.0.0 of the Cabal library
一个更好的命令行工具,可以通过名为stack的FPComplete组来安装Haskell二进制文件和库,这意味着您可以安装ghc-mod (在项目外部以使其全局),并且可以正常工作。该二进制文件将被安装并应放在您的路径上,以便您的编辑器可以找到它。stack install ghc-mod
~/.local/bin
我将把下面的内容留给任何想知道阴谋地狱真正含义的人。
我在Haskell reddit上询问时,NihillstDandy解释说Mac OS X的GHC没有注册Cabal库。对于从http://ghcformacosx.github.io/进行的安装,情况并非如此。它确实注册了Cabal库。
ghc-mod需要cabal库才能工作,但无法与cabal库一起编译。而是使用cabal-helper进行编译,以查看您是否具有cabal库的注册版本。如果找不到,cabal-helper-wrapper
则将安装私有副本,在这种情况下,安装与cabal-install编译版本相同的版本cabal-1.22.0.0会很累。
当我安装DanielG's Fork时,它适用于我当前的项目,但是在其他项目中对其进行测试后,您却遇到了相同的错误。这是叉子的问题,不是Haskell的问题(据我所知)。
所以,当我把这个帖子放在一起的时候,ghc-mod是为GHC-7.10修复的。感谢DanielG!
git clone https://github.com/DanielG/ghc-mod
cd ghc-mod
cabal install -j4
并且,如果出现错误消息“ setup-Simple-Cabal-1.22.2.0-x86_64-osx-ghc-7.10.1:需要程序'happy'版本> = 1.17,但找不到它”。
cabal install happy -j4
对于其他任何问题都一样,它应该可以工作。(尽管您已经满意安装了,所以应该可以使用)。
文章的其余部分是关于如何将cabal可执行文件(也称为cabal-install)降级到版本1.20.0.3。尽管您确实可以使用它来降级到任何版本。由于有一个ghc-mod的工作叉与GHC-7.10和cabal-1.22一起使用,因此您无需降级即可修复ghc-mod。
我只是将其余的帖子留在这里,因为不幸的是,这是整个Haskell的问题。Halcyon和nix是解决Haskell在这方面的缺点的方法。
当我写这篇文章时,用GHC-7.10和低于7.10版本编译的ghc-mod或任何fork都用cabal-1.22沙箱破坏了。
但是,即使您用GHC-7.8.4(7.10之前的版本)和cabal-1.20.0.3编译ghc-mod,您仍然不能在cabal-1.22及更高版本创建的沙箱中使用ghc-mod。因此,使用ghc-mod的唯一方法是将整个系统降级为cabal-1.20.0.3或不使用沙箱。这意味着您仍然可以使用GHC-7.10,但是必须使用旧版本的cabal。那是除非您要等到召集人或其他人为GHC-7.10修复它时为止。已经有一个多星期了,但是某种Haskell程序员用叉子修复了它(见上文)。
如果这是您仍然想要的,这里是如何使用GHC-7.8.4和cabal-1.20.0.3编译ghc-mod。另外,我将可执行文件cabal-1.22替换为较旧的cabal-1.20.0.3。注意,将源下载到哪个目录都没有关系。
tar -xf path_to_zipped_source
cd path_to_ghc-7.8.4
下一步将在您安装ghc-7.10的同一文件夹中将ghc-7.8.4作为ghc-7.8.4安装。-j4告诉make使用4个线程来编译它。
./configure
make install -j4
要获得正确版本的阴谋集团,我们可以要求阴谋集团获得它。
cabal get cabal-install-1.20.0.3
cd cabal-install-1.20.0.3
现在使用ghc-7.8.4安装cabal。在这里,cabal-1.22将提取所有内容,并应向您发出有关安装其他版本的cabal库的警告(不要与cabal-install混淆),这不会引起问题。
cabal --with-compiler=ghc-7.8.4 install
因此,现在您应该已经安装了cabal-1.20.0.4,但没有安装在路径上。它将在〜/ .cabal / bin中。我们需要将此设置为全局,因此删除cabal-1.22(它仅删除符号链接)。
并创建到cabal-1.20.0.4的符号链接。顺便说一句,您将需要删除使用cabal-1.22制作的所有沙箱,然后使用cabal-1.20.0.4对其进行重新制作。
如果您没有realpath
,则只需输入cabal的完整路径即可。我用它来纵容。
cd ~/.cabal/bin
现在这就是我在Mac上编译ghc-mod的方式(您可能会遇到自己的问题)。我不知道为什么cabal不能在一个电话中做到这一点,但最终还是成功了。
cabal --with-compiler=ghc-7.8.4 install happy
cabal --with-compiler=ghc-7.8.4 install haskell-src-exts-1.16.0.1
cabal --with-compiler=ghc-7.8.4 install hlint-1.9.19
cabal --with-compiler=ghc-7.8.4 install ghc-mod
现在您应该可以从任何地方调用ghc-mod了。为了测试它只需输入ghc-mod
你有后cabal sandbox init
。如果它没有引发任何错误,那么您就可以了。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句