How to run shake without stack

244 views Asked by At

I created the recommended build.sh file from the "Running" section of the Shake manual:

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

but running that script gives the following error:

[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
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I did cabal v2-install shake --installpath=bin, but still get the same error afterwards. I also tried bin/shake but get the same error.

I tried adding -package shake to the ghc command in the build.sh, but get this error:

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

Adding -v as suggested gives this error:

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)

What is the correct way to use Shake without Haskell stack (preferably using only ghc 8.8 installed with ghcup and/or with cabal-install v2 commands)?

1

There are 1 answers

0
avh4 On

I figured out I need to use the --lib flag with cabal new-install otherwise only the shake binary gets installed.

After running cabal new-install --lib shake, the original build.sh script with the addition of -package shake to the ghc arguments now works! And runhaskell -package shake Shakefile.hs also works now.