如何在没有堆栈的情况下进行摇动

问题描述

我从"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添加ghc中的build.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 stack的情况下使用Shake的正确方法是什么(最好仅使用通过ghcup和/或cabal-install v2命令安装的ghc 8.8)?

解决方法

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

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