构建 Pandoc 时出错:$['ghc-options'] 中的错误:解析字段 'ghc-options' 失败:包名称无效:“$locals”

Error building Pandoc: Error in $['ghc-options']: failed to parse field 'ghc-options': Invalid package name: "$locals"

我正在尝试从源代码构建 Pandoc。按照 [使用 Stack 的步骤],我 运行

$ stack setup

然后我得到这个错误:

$ stack setup
Could not parse '/home/adam/software/pandoc/stack.yaml':
Aeson exception:
Error in $['ghc-options']: failed to parse field 'ghc-options': Invalid package name: "$locals"
See http://docs.haskellstack.org/en/stable/yaml_configuration/

这是怎么回事?

根本原因

我的 Stack 版本已过时。

Pandoc 的 stack.yaml 使用 $locals key in ghc-options. This key is only supported from 1.6.0 onward:

NOTE: Prior to version 1.6.0, the $locals, $targets, and $everything keys were not support.

我的 Stack 版本是 1.5.1(来自 Ubuntu 的存储库)。

解决方案

只需执行

即可升级 Stack
$ stack upgrade