flycheck-haskell and doctest don't work on Cabal 3.0 v2-build project

為{幸葍}努か 提交于 2020-01-04 07:55:14

问题


I tried to create a Nix-style local build (v2-build) project on Cabal 3.0.
But several development tools (flycheck-haskell and doctest) don't work.
They worked on new-build project on Cabal 2.4.
Error message says they cannot find dependencies, as far as I read.

$ cabal v2-clean
$ cabal v2-build
$ cabal v2-test
Build profile: -w ghc-8.8.1 -O1
In order, the following will be built (use -v for more details):
 - hstest9-0.1.0.0 (test:doctestd) (first run)
Configuring test suite 'doctestd' for hstest9-0.1.0.0..
Preprocessing test suite 'doctestd' for hstest9-0.1.0.0..
Building test suite 'doctestd' for hstest9-0.1.0.0..
[1 of 1] Compiling Main             ( test/doctest-driver.hs, /Users/user/work/hstest9/dist-newstyle/build/x86_64-osx/ghc-8.8.1/hstest9-0.1.0.0/t/doctestd/build/doctestd/doctestd-tmp/Main.o )
Linking /Users/user/work/hstest9/dist-newstyle/build/x86_64-osx/ghc-8.8.1/hstest9-0.1.0.0/t/doctestd/build/doctestd/doctestd ...
Running 1 test suites...
Test suite doctestd: RUNNING...

/Users/user/work/hstest9/src/MyLib.hs:3:1: error:
    Could not find module ‘Control.Effect’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
3 | import Control.Effect
  | ^^^^^^^^^^^^^^^^^^^^^

Test suite doctestd: FAIL
Test suite logged to:
/Users/user/work/hstest9/dist-newstyle/build/x86_64-osx/ghc-8.8.1/hstest9-0.1.0.0/t/doctestd/test/hstest9-0.1.0.0-doctestd.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal: Tests failed for test:doctestd from hstest9-0.1.0.0.

回答1:


Your doctest doesn't find proper GHC_ENVIRONEMNT.

Since Cabal 3.0, cabal v2-build doesn't generate environment files by default.

Since Cabal 3.0, defaults to never. Before that, defaulted to creating them only when compiling with GHC 8.4.4 and older (GHC 8.4.4 is the first version that supports the -package-env - option that allows ignoring the package environment files). https://www.haskell.org/cabal/users-guide/nix-local-build.html#cfg-field-write-ghc-environment-files

So you should set this option on v2-build.

$ cabal v2-build --write-ghc-environment-files=ghc8.4.4+

Or you can write this in $HOME/.cabal/config for default cabal behavior.

write-ghc-environment-files: ghc8.4.4+


来源:https://stackoverflow.com/questions/58027908/flycheck-haskell-and-doctest-dont-work-on-cabal-3-0-v2-build-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!