Since I’m still stuck, here is a detailed explanation of what I did.
(I’m on NixOS 19.03, I use ghc-8.6.5 and stack 2.1.1.1)
- Install
exercism
package (nix-env -i exercism
) - Then
exercism download --exercise=hello-world --track=haskell
will download and install the data in/home/jlucas/exercism/haskell/hello-world
. - After
cd /home/jlucas/exercism/haskell/hello-world
, in the file./stack.yaml
, I addedcompiler: ghc-8.6.5
(or whatever is your system version I guess) - Next
stack build
works for me - But
stack test
returns the next error log (I only pasted relevant lines)
...
WARNING: Ignoring stm's bounds on base (>=4.3 && <4.12); using base-4.12.0.0.
...
stm > Building library for stm-2.4.5.0..
...
stm > /run/user/1000/stack-a8a4ca0abf4d9831/stm-2.4.5.0/Control/Monad/STM.hs:34:9: error: Not in scope: ‘always’
...
stm > /run/user/1000/stack-a8a4ca0abf4d9831/stm-2.4.5.0/Control/Monad/STM.hs:35:9: error: Not in scope: ‘alwaysSucceeds’
...
-- While building package stm-2.4.5.0 using:
/home/jlucas/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1 build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Progress 14/18
The error seems to be caused by the test dependency, stm
, that cannot be built, isn’t it ?
Just to check, I verified that I could create an empty stack project. from scratch, following the guide. Here is what I did
-
At first,
stack new helloworld
, returned the errorCannot determine project root directory for Docker sandbox.
-
Thus, in
~/.stack/config.yaml
I disabled nix withnix: enable: false
and
stack new helloworld
worked -
Next, I did,
cd helloworld stack build
The last command returned the error:
I don't know how to install GHC on your system configuration, please install manually
-
Thus, in
~/.stack/config.yaml
I re-enabled nix :nix: enable: true
With that,
stack build
did work… -
stack test
also worked.
Thus, at the end, I was able to build a full project from scratch. What was surprising is that I had to first disable nix to create the project, then to enable nix to build and test the project.