Haskell Mac OS X 10.11 的阴谋集团问题? (不能满足-package-id)

Haskell cabal issue with Mac OS X 10.11? (cannot satisfy -package-id)

我在 Mac OS X 10.11 上为 El-capitan 使用了最新的 Haskell 平台 7.10.2-a (https://www.haskell.org/platform/mac.html)。

当我尝试使用 cabal install yesod 安装 yesod 时,我收到多条错误消息,例如:

Building email-validate-2.1.3...
Building http-api-data-0.2.1...
Building fast-logger-2.4.1...
Building http-date-0.0.6.1...
Failed to install crypto-random-0.0.9
Build log ( /Users/smcho/.cabal/logs/crypto-random-0.0.9.log ):
Configuring crypto-random-0.0.9...
Building crypto-random-0.0.9...
Preprocessing library crypto-random-0.0.9...
<command line>: cannot satisfy -package-id vector-0.11.0.0-730f99979d41c11c3a1ef069844b5f57
    (use -v for more information)
Failed to install email-validate-2.1.3
Build log ( /Users/smcho/.cabal/logs/email-validate-2.1.3.log ):
Configuring email-validate-2.1.3...

错误模式几乎相同:cannot satisfy -package-id

例如,cabal install aeson 给出 cannot satisfy -package-id attoparse... 错误。

Resolving dependencies...
Configuring aeson-0.10.0.0...
Building aeson-0.10.0.0...
Failed to install aeson-0.10.0.0
Build log ( /Users/smcho/.cabal/logs/aeson-0.10.0.0.log ):
Configuring aeson-0.10.0.0...
Building aeson-0.10.0.0...
Preprocessing library aeson-0.10.0.0...
<command line>: cannot satisfy -package-id attoparsec-0.13.0.1-99b4df28644e63383f308c810764a8bb
    (use -v for more information)
cabal: Error: some packages failed to install:
aeson-0.10.0.0 failed during the building phase. The exception was:
ExitFailure 1

但是,attoparsec 库似乎安装没有问题。

smcho@macho ~> cabal install attoparsec
Resolving dependencies...
All the requested packages are already installed:
attoparsec-0.13.0.1
Use --reinstall if you want to reinstall anyway.

可能出了什么问题?

这可能会引起争议,但恕我直言,随着 stack 的出现,haskell 平台和 cabal(直接使用时)现在基本上已被弃用。

堆栈将:

  1. 自动为您安装 haskell (stack setup)
  2. 自动沙盒(并在项目之间智能共享沙盒)
  3. 完全避免阴谋地狱(以我的经验)

我可以从 brew 安装 yesod。

卸载haskell-plaftorm

  • /Library/Haskell/bin/uninstall-hs thru 7.10.2

安装 ghc

  • brew install ghc
    • brew link ghc

安装堆栈

  • brew install haskell-stack

安装 Yesod

  • stack install yesod
  • stack install yesod-bin

使用 Yesod

    • stack runghc hello-world.hs

使用 Yesod 进行开发

  • 我不确定,但我必须先 运行 stack exec yesod build
  • stack exec yesod devel

使用 keter 部署 Yesod

  • 删除config/keter.yaml
  • 中的第一行
  • stack exec yesod keter,您将在 dist/bin 中获得一个二进制文件,其中包含 运行.
  • 所需的大部分文件
  • 将二进制文件作为独立服务器执行。

根据建议 here,您看到的 cannot satisfy -package-id 错误可能是由于缓存过期所致。

如果 运行 ghc-pkg check 警告您缓存已过期,那么 运行 ghc-pkg recache 可能会解决您的问题。

整个早上我都运行陷入cannot satisfy -package-id问题(不是yesod,而是其他各种软件包)。 ghc-pkg recache 解决了我的问题。希望这有帮助。