Stack 一直使用错误的 GHC 版本

Stack keeps using wrong GHC version

我已经在我的 (Debian 9) 系统上安装了 ghc 的 8.6.5 版本,这是唯一可用的版本(查看下面的详细信息)。我正在尝试构建这个项目:https://github.com/deech/fltkhs-themes-demo

所以我安装了最新的堆栈(Version 2.1.3, Git revision 636e3a759d51127df2b62f90772def126cdf6d1f (7735 commits) x86_64 hpack-0.31.2)并尝试编译项目:

git clone git@github.com:deech/fltkhs-themes-demo.git
cd fltkhs-themes-demo/
stack build --flag fltkhs:bundled

我最初得到的是这样的:

Stack has not been tested with GHC versions above 8.6, and using 8.8.2, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
asset-bundle      > configure

现在,我已经将 ~/.stack/config.yaml 设置为系统 ghc:

% stack config set system-ghc --global true
/home/mark/.stack/config.yaml has been updated.

设置似乎正确:

% cat ~/.stack/config.yaml
templates:
  params: null
system-ghc: true

那么为什么堆栈使用 ghc 8.8.2?

这更奇怪了,因为该项目似乎在其 stack.yaml:

中使用了指定的 ghc 版本
cat fltkhs-themes-demo/stack.yaml
resolver: lts-15.0
allow-newer: true
extra-deps:
- fltkhs-0.8.0.3
- fltkhs-themes-0.2.0.3
- load-font-0.1.0.3
- asset-bundle-0.1.0.1

如何让它使用 ghc 8.6.5?

关于我的系统的更多详细信息:

user@system ~ % ls -1 .ghcup/bin
cabal
ghc
ghc-8.6
ghc-8.6.5
ghci
ghci-8.6
ghci-8.6.5
ghc-pkg
ghc-pkg-8.6
ghc-pkg-8.6.5
ghcup
haddock
haddock-8.6
haddock-8.6.5
haddock-ghc
haddock-ghc-8.6
haddock-ghc-8.6.5
hp2ps
hp2ps-8.6
hp2ps-8.6.5
hpc
hpc-8.6
hpc-8.6.5
hsc2hs
hsc2hs-8.6
hsc2hs-8.6.5
runghc
runghc-8.6
runghc-8.6.5
runhaskell
runhaskell-8.6
runhaskell-8.6.5

user@system ~ % cabal --version
cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library 

user@system ~ % ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5

user@system ~ % which ghc
/home/user/.ghcup/bin/ghc

每个 Stackage 解析器都绑定到特定的 GHC 版本。既然如此,如果您选择的解析器使用的 GHC 版本与您在系统范围内安装的版本不同,Stack 将安装它,而不管 system-ghc 选项。作为the Stack FAQ puts it

Note that stack can only use a system GHC installation if its version is compatible with the configuration of the current project, particularly the resolver setting.

在您的情况下,lts-15.0 使用 GHC 8.8.2,如 its Stackage page. If you want to use your system's 8.6.5, you can switch the resolver to lts-14.27, which at the moment is the most recent LTS that uses 8.6.5 中所示。