问题描述
我从"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)
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 shake
到ghc
参数中就可以使用了!并且runhaskell -package shake Shakefile.hs
现在也可以使用。