Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hspec-discover file fails with "could not execute: hspec-discover" #544

Closed
ProofOfKeags opened this issue Oct 27, 2020 · 4 comments
Closed
Labels
can-workaround component: hie-bios status: blocked Not actionable, because blocked by upstream/GHC etc. type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@ProofOfKeags
Copy link

Subject of the issue

Problems tab has a persistent issue (sometimes 2 copies) of
haskell-language-server-8.10.2: could not execute: hspec-discover

Background

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.

My Details

{-# 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

Your environment

  • HLS: 0.5.1 on ghc8.10.2
  • Editor: VSCode
  • Project base: stack / resolver = nightly-2020-09-29
  • hie.yaml:
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"

Steps to reproduce

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

Expected behaviour

I'd expect that there was no error in my problems tab.

Actual behaviour

There is an error in my problems tab, enumerated in the subject

Speculation

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.

@wz1000
Copy link
Collaborator

wz1000 commented Oct 27, 2020

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

@jneira
Copy link
Member

jneira commented Oct 27, 2020

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

@jneira jneira added can-workaround component: hie-bios status: blocked Not actionable, because blocked by upstream/GHC etc. type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Oct 27, 2020
@jneira
Copy link
Member

jneira commented Oct 27, 2020

If you dont mind, i would close this as duplicate. You can track the progress in the original issue: #176

@ProofOfKeags
Copy link
Author

Close away

@jneira jneira closed this as completed Oct 27, 2020
pepeiborra pushed a commit that referenced this issue Dec 27, 2020
Looks like the new version of hlint has a couple of new hints.

changelog_begin
changelog_end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can-workaround component: hie-bios status: blocked Not actionable, because blocked by upstream/GHC etc. type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants