haskell - 如何在没有堆栈的情况下运行 shake

标签 haskell cabal-install shake-build-system cabal-new

我从 "Running" section of the Shake manual 创建了推荐的 build.sh 文件:

#!/bin/sh
mkdir -p _shake
ghc --make Shakefile.hs -v -rtsopts -threaded -with-rtsopts=-I0 -outputdir=_shake -o _shake/build && _shake/build "$@"

但运行该脚本会出现以下错误:

[1 of 1] Compiling Main             ( Shakefile.hs, _shake/Main.o )

Shakefile.hs:1:1: error:
    Could not find module ‘Development.Shake’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
1 | import Development.Shake
  | ^^^^^^^^^^^^^^^^^^^^^^^^

Shakefile.hs:2:1: error:
    Could not find module ‘Development.Shake.Command’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
2 | import Development.Shake.Command
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Shakefile.hs:3:1: error:
    Could not find module ‘Development.Shake.FilePath’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
3 | import Development.Shake.FilePath
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Shakefile.hs:4:1: error:
    Could not find module ‘Development.Shake.Util’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
4 | import Development.Shake.Util
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

我做了 cabal v2-install shake --installpath=bin,但之后仍然出现同样的错误。我也尝试了 bin/shake 但得到了同样的错误。

我尝试将 -package shake 添加到 build.sh 中的 ghc 命令,但出现此错误:

<command line>: cannot satisfy -package shake
    (use -v for more information)

按照建议添加 -v 会出现此错误:

Glasgow Haskell Compiler, Version 8.8.4, stage 2 booted by GHC version 8.8.3
Using binary package database: /Users/avh4/.ghcup/ghc/8.8.4/lib/ghc-8.8.4/package.conf.d/package.cache
package flags [-package shake{package shake True ([])}]
loading package database /Users/avh4/.ghcup/ghc/8.8.4/lib/ghc-8.8.4/package.conf.d
<command line>: cannot satisfy -package shake
    (use -v for more information)

在没有 Haskell stack 的情况下使用 Shake 的正确方法是什么? (最好只使用通过 ghcup 和/或 cabal-install v2 命令安装的 ghc 8.8)?

最佳答案

我发现我需要在 cabal new-install 中使用 --lib 标志,否则只会安装 shake 二进制文件。

运行 cabal new-install --lib shake 后,原始 build.sh 脚本加上 -package shakeghc 参数现在可以使用了! runhaskell -package shake Shakefile.hs 现在也可以使用了。

关于haskell - 如何在没有堆栈的情况下运行 shake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64020887/

相关文章:

haskell - 有没有一种简单的方法可以将派生 Enum 的数据类型转换为列表?

haskell - cabal 更新错误 : "ErrorMisc Unsuccessful HTTP code: 404"

c++ - 使用 Shake 和 Stack 构建链接到 Haskell 库的 C++ 项目

haskell - 在严格的、不纯粹的语言中,柯里化(Currying)/偏应用如何工作?

haskell - yesod 测试 - 缺少依赖 yesod-test

haskell - cabal 安装 `gcc' 在阶段 `C Compiler' 失败

haskell - 使用 shake 为一组文件定义规则,在构建时未知

haskell - 如何输出/p :Platform ="Any CPU" as quoted from shake cmd?

scala - State monad 在具有可变(本地)变量的语言(例如 Scala)中是否需要/有用?

haskell - Cabal 在 ubuntu 12.04 上安装reactive-banana-wx