haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Wrong `could not execute: tasty-discover` (revisit after haskell/hie-bios#187)

Open sir4ur0n opened this issue 5 years ago • 13 comments

When using a preprocessor (tasty-discover) for our tests, we get a wrong error from HLS, while compilation is fine.

See minimal repo to reproduce the issue: https://github.com/Sir4ur0n/hls-bug-preprocessor

  • stack test works fine
  • haskell-language-server returns an error:
File:     /home/sir4ur0n/sandbox/hls-bug-preprocessor/test/Spec.hs
Hidden:   no
Range:    1:0-2:0
Source:   compiler
Severity: DsError
Message:  haskell-language-server: could not execute: tasty-discover
Files that failed:
[INFO] finish: User TypeCheck (took 0.57s) * /home/sir4ur0n/sandbox/hls-bug-preprocessor/test/Spec.hs

While we might tell hie.yaml to ignore (cradle none) the Spec.hs file in particular, I don't see a reason why this even fails. HLS should support such files.

Thank you!

sir4ur0n avatar Jun 25 '20 12:06 sir4ur0n

Hi, thank you for the bug report! The same issue exists in hie: https://github.com/haskell/haskell-ide-engine/issues/1500 And the upstream issue is in hie-bios: https://github.com/mpickering/hie-bios/issues/125

Work-around: make tasty-discover available in your path.

fendor avatar Jun 25 '20 12:06 fendor

I just tested by adding haskell.packages.${ghcCompiler}.tasty-discover in my shell.nix and indeed, HLS no longer complains about Spec.hs, thank you @fendor , I appreciate the help and quick response time!

Let's use this issue to document this limitation, as well as link to upstream issue in hie-bios.

I'll try to propose a PR some time this week

sir4ur0n avatar Jun 25 '20 13:06 sir4ur0n

I have opened #177 to document this limitation.

Should we keep this issue open to track the original issue?

sir4ur0n avatar Jun 26 '20 13:06 sir4ur0n

Yeah, I think that is good idea.

fendor avatar Jun 26 '20 13:06 fendor

Happen to know the response.

Back in the day (but most probably before this report), in tasty-discover put the info on how to properly bootstrap it.

Notice build-tool-depends: in: https://github.com/haskell-works/tasty-discover#configure-cabal-or-hpack-test-suite

  • tasty-discover is not really a library dependency, it is a testing tool executable.
  • tasty-discover should not be build-depends: it is build-tool-depends:

When tool is in .cabal description build-tool-depends: - Cabal automatically installs & uses the executable.

P.S. BTW cabal2nix also supports, respects, requires & handles build-tool-depends:. & the proper bootstrap of tasty-discover in .cabal is a requirement for the project to be properly imported into Nixpkgs. As a result, Nix description would build the package without tasty-discover in the environment, but at runtime tasty-discover would be provided. (Let us have a moment of respect for the work done by the initial Haskell Nixpkgs maintainer we all know.)

Anton-Latukha avatar Dec 21 '21 07:12 Anton-Latukha

& #1159 also was merged

Anton-Latukha avatar Dec 21 '21 07:12 Anton-Latukha

the original reporter mentioned stack, so not sure if it is specific to cabal did you remove the other labels by accident? afaik it is blocked upstream on a hie-bios issue and it has a workaround...

jneira avatar Dec 21 '21 08:12 jneira

Know that workaround, used to use it.

Stack configuration depends on Cabal configuration. Stack to work needs to respect Cabal descriptions (for example, as cabal2nix does). If Cabal build-tool-depends: is not respected by it - that implies Stack has own version of the entry for it & it only needs to be looked-up then.

#1159 implies the support of the directive is supported by HLS, that is why thought to close the report.

The current hie-bios report is https://github.com/haskell/hie-bios/issues/187,

So then, yes - it still needs to be open.

Anton-Latukha avatar Dec 21 '21 08:12 Anton-Latukha

Thanks for bouncing me on this.

Anton-Latukha avatar Dec 21 '21 09:12 Anton-Latukha

Tentatively closing since I haven't seen recent complaints about this

michaelpj avatar Jan 11 '24 09:01 michaelpj

That issue is still open, we haven't fixed it in hie-bios. There currently is no plan to fix it, mainly because the issue feels minor, but I would keep the issue open.

fendor avatar Jan 11 '24 09:01 fendor

Hi everyone,

I'm encountering this same issue and find it quite frustrating. Ideally, I would like to be able to install the language server and expect everything to work seamlessly without additional manual steps, such as manually installing tools which are already specified in my cabal project files. I tried looking into what is causing the bug but its not clear where to start.

Best regards, webdevred

webdevred avatar Jun 10 '25 13:06 webdevred

@webdevred The first step is to record the PATH in hie-bios and add it to the ComponentOptions field. Then update cabal, stack, etc... cradles to include the path information if available. stack offers stack path command, and in cabal we might need to additionally record the $PATH var in the wrappers/cabal and wrappers/cabal.hs. Once that's done, we can think about updating HLS. I am not 100% how we can handle the $PATH correctly, if we have a different PATH for each component, what should happen? Maybe just merge all PATH vars, and set them globally.

Once hie-bios has been updated, we need to update Session.hs in HLS.

fendor avatar Jun 10 '25 18:06 fendor