Problems tab has a persistent issue (sometimes 2 copies) of
haskell-language-server-8.10.2: could not execute: hspec-discover
Hspec-Discover is a "magic" tool that allows you to just have test files that get auto-assembled into a main method such that the "spec :: Spec" signature is evaluated in Hspec's environment. I do not understand in the slightest how it works under the hood, but it involves a single {-# OPTIONS_GHC ... #-} pragma that can discover all these test modules.
{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}
Relevant stanza in package.yaml
tests:
agent-test:
source-dirs: test
main: Main.hs
ghc-options:
- -Wall
- -fdefer-typed-holes
dependencies:
- ambassador-agent
- hspec >=2.0.0
- hspec-expectations
- hedgehog
- yesod-test
- random
when:
- condition: false
other-modules: Paths_ambassador_agent
cradle:
stack:
- path: "./src"
component: "ambassador-agent:lib"
- path: "./app/main.hs"
component: "ambassador-agent:exe:agent"
- path: "./test"
component: "ambassador-agent:test:agent-test"
- path: "./"
component: "ambassador-agent:lib"
I have not put together a minimal repro, but I suspect this can be done by having a "trivial" library, and a test module that follows the instructions here: https://hspec.github.io/hspec-discover.html
I'd expect that there was no error in my problems tab.
There is an error in my problems tab, enumerated in the subject
I'm guessing based on how the error is worded, that hls is attempting to execute hspec-discover itself. If it is not in hls's "PATH" then it could just not be finding it. That said, my project is stack based, and a stack exec hspec-discover yields usage info, so it is definitely available inside the stack environment which I'd imagine hls has access to.
The next guess is that for some reason the arguments aren't being properly given to it by hls. But I would have guessed that this would be delegated to GHC and GHC has well defined semantics around how arguments are supplied to these sorts of pragmas: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/phases.html#ghc-flag--F
I don't have any ideas besides that. Open to thoughts.
hls gets the ghc flags from stack, but AFAIK it doesn't use the $PATH. Perhaps this is something that should be exposed via the hie-bios interface.
/cc @fendor
Hi, thanks for the detailed bug report.
I'm guessing based on how the error is worded, that hls is attempting to execute hspec-discover itself. If it is not in hls's "PATH" then it could just not be finding it
That is exactly what is happening. It was reported in #176 and documented in the readme https://github.com/haskell/haskell-language-server#preprocessor with #177
It is blocked upstream on hie-bios and the workaround for now is put the executable in PATH
If you dont mind, i would close this as duplicate. You can track the progress in the original issue: #176
Close away
Most helpful comment
If you dont mind, i would close this as duplicate. You can track the progress in the original issue: #176