3

我从Shake 手册的“运行”部分创建了推荐的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命令ghcbuild.sh但收到此错误:

<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 堆栈的情况下使用 Shake 的正确方法是什么(最好只使用通过ghcup和/或 cabal-install v2 命令安装的 ghc 8.8 )?

4

1 回答 1

4

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

运行后,添加参数的cabal new-install --lib shake原始build.sh脚本现在可以工作了!现在也有效。-package shakeghcrunhaskell -package shake Shakefile.hs

于 2020-09-23T04:34:56.920 回答