Fay 找不到 fay-base

Fay can't find fay-base

我想使用 Fay with Yesod,但 Fay 类型检查无法正常工作。 将不胜感激任何建议。

$ stack build                                                                                                                           
[ 9 of 11] Compiling Handler.Home     ( src/Handler/Home.hs, .stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-2.4.0.1/build/Handler/Home.o )                                                                 

/home/user/code/myproject/src/Handler/Home.hs:121:13: error:
    _ Exception when trying to run compile-time code:
        ghc-pkg describe error:
Timestamp 2019-05-07 18:46:44 UTC for /opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d/package.cache
ghc-pkg: cannot find package fay-base  <- ########### Why?

GHC package manager version 8.6.5
using cache: /opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d/package.cache
db stack: ["/opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d"]
flag db stack: ["/opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d"]

CallStack (from HasCallStack):
  error, called at src/Fay/Compiler/Packages.hs:70:24 in fay-0.24.0.3-CdLcUWVJEOpLCiYHkNVTai:Fay.Compiler.Packages                                                                                                                 
      Code: fayFile' (ConE 'StaticR) "HelloWorld"
    _ In the untyped splice: $(fayFile' (ConE 'StaticR) "HelloWorld")
    |
121 |             $( fayFile' (ConE 'StaticR) "HelloWorld" )
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Fay 包还没有堆叠起来,所以我将它们添加到 stack.yaml 作为 extra-deps:

extra-deps:                                                                                                     - fay-0.24.0.3
- fay-base-0.21.1.1
- fay-dom-0.5.0.1
- fay-text-0.3.2.2
- yesod-fay-0.10.0

package.yamldependencies:

dependencies:
... more dependencies ...  
- fay == 0.24.0.3
- fay-base == 0.21.1.1
- fay-dom == 0.5.0.1
- fay-text == 0.3.2.2
- yesod-fay == 0.10.0

Fay 包在 local package database:

$ stack exec -- ghc-pkg list                                                                                                                                                                             
/opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d
    Cabal-2.4.0.1
    array-0.5.3.0
    base-4.12.0.0
    ...
/home/user/.stack/snapshots/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/lts-13.30/8.6.5/pkgdb
    Cabal-2.4.1.0
    Diff-0.3.4
    HUnit-1.6.0.0
    ...
    yesod-1.6.0
    yesod-core-1.6.14
    yesod-form-1.6.5
    yesod-newsfeed-1.6.1.0
    yesod-persistent-1.6.0.2
    yesod-static-1.6.0.1
/home/user/code/myproject/.stack-work/install/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/lts-13.30/8.6.5/pkgdb
    fay-0.24.0.3
    fay-base-0.21.1.1
    fay-dom-0.5.0.1
    fay-text-0.3.2.2
    yesod-fay-0.10.0

但是尝试将 HASKELL_PACKAGE_SANDBOX 设置为本地数据库 Fay Troubleshooting suggests doesn't work, because sandboxes containing the string .stack are ignored in yesod-fay

如果我从 yesod-fay 中删除该检查并强制 --package-db 指向本地数据库,它仍然不起作用,抱怨 fay-base 找不到fay 包。

$ stack build
    /home/user/code/myproject/src/Handler/Home.hs:121:13: error:
        • Exception when trying to run compile-time code:
            Unable to compile Fay module "HelloWorld":

    ghc: <command line>: cannot satisfy -package fay-base-0.21.1.1: 
        fay-base-0.21.1.1-91eIy2f24Wa5OHg9LMre7 is unusable due to missing dependencies:
          fay-0.24.0.3-CdLcUWVJEOpLCiYHkNVTai
        (use -v for more information)

    CallStack (from HasCallStack):
      error, called at ./Yesod/Fay.hs:483:3 in yesod-fay-0.10.9999-CzTT9fyZ6636pi0gIof7Ge:Yesod.Fay
          Code: fayFile' (ConE 'StaticR) "HelloWorld"
        • In the untyped splice: $(fayFile' (ConE 'StaticR) "HelloWorld")
        |
    121 |             $( fayFile' (ConE 'StaticR) "HelloWorld" )
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

更新:不使用 satck 或 cabal 并使用系统范围内安装的软件包,不会发生此错误。我想问题出在我的本地堆栈包数据库中(.stack-work 中的那个)

我得出的结论是 fay 不适用于堆栈。