Closed mouse07410 closed 4 years ago
Thank you for your awesomely detailed bug report! To me, it looks like this is the manifestation of a known bug in hie-bios and cabal, see https://github.com/mpickering/hie-bios/issues/164 and the underlying cause https://github.com/haskell/cabal/issues/6622. Fix is https://github.com/haskell/cabal/pull/6623
Workaround: provide a full mapping from path to component.
Thank you for your awesomely detailed bug report!
My pleasure - hope I can maintain that level!
To me, it looks like this is the manifestation of a known bug in
hie-bios
andcabal
... Fix is haskell/cabal#6623
So, this bug is not in HIE, but in Cabal itself? But the builds and runs seem to work, somehow...?
Workaround: provide a full mapping from path to component
Please pardon my ignorance - could you show what you mean/what the workaround should look like, and in what file(s)?
Also, if I don't want to wait an unpredictable amount of time before the 6623 ends up in a released version of Cabal:
a. Should I just clone Cabal repo, merge that PR, build, and install in place of a released Cabal?
b. To get HIE employ this fix - probably having cabal-install
executable is not good enough? How do I build HIE to incorporate this fix? Thanks!
Please take a look at https://github.com/haskell/cabal/issues/6659# - looks like I cannot build a decent cabal-install
from its Git repo.
So, this bug is not in HIE, but in Cabal itself? But the builds and runs seem to work, somehow...?
That is unrelated. What essentially happens in hie-bios (quite literally), with your hie.yaml
, is the invocation cabal repl test/Spec.hs
, which you can test in your terminal. In this case, it ought to fail with the same message as returned by your lsp message (piped through putStrLn
):
Fail on initialisation for "/Users/ur20980/Src/Str2Split/test/Spec.hs".
Failed to parse result of calling cabal
cabal: Unknown target '/Users/ur20980/Src/Str2Split/test/Spec.hs'.
The package Str2Split has no file target 'test/Spec.hs'.
Please pardon my ignorance - could you show what you mean/what the workaround should look like, and in what file(s)?
Like what we do in haskell-ide-engine: https://github.com/haskell/haskell-ide-engine/blob/master/hie.yaml.cbl
a. Should I just clone Cabal repo, merge that PR, build, and install in place of a released Cabal? b. To get HIE employ this fix - probably having cabal-install executable is not good enough? How do I build HIE to incorporate this fix? Thanks!
It should be enough to just checkout the pr and install it, via cabal install exe:cabal
(assuming cabal-install 3.0.0.0 or newer).
HIE is not built against Cabal, it is enough if this modified version is on your PATH, e.g. cabal repl test/Spec.hs
succeeds in your terminal, then it works with HIE.
@fendor unfortunately, it looks like I cannot build a working cabal-install
from local sources. It builds fine, but any attempt to actually install something with it results in abort on failed assertion.
As I said, my setup is building shared libraries and dynamic executables. Is there a way to build cabal-install
with static libraries (it's impossible to force static executables on MacOS because some of the system libraries are shared only)? Or can you see another possible cause for this failed assertion? It's now 100% consistent, while downloaded cabal-install
binaries appear to work fine...
Also, I'm confused with hie.yaml.cbl
- what are "components"? Targets in <project>.cabal
? Names of the executable or library files? Or...?
@fendor I give up. I don't know Haskell well enough to either succeed building Cabal from source, or even enjoy the process. Nor do I understand what should go into hie.yaml
- what is considered a "component"? When should "path" point at a directory (like - path: "./test/dispatcher/"
) and when at a specific file (like - path: "./app/MainHie.hs"
)? So far, no matter what I'm doing I get
$ cabal repl test/Spec.hs
cabal: Unknown target 'test/Spec.hs'.
The package Str2Split has no file target 'test/Spec.hs'.
Here's my latest experimental hie.yaml
, which unquestionably is incorrect:
cradle:
cabal:
- path: "./"
component: "lib:Str2Split"
- path: "./test/Spec.hs"
component: "test-suite"
- path: "./app/Main.hs"
component: "executable"
Could you do me a favor? My sample project https://github.com/mouse07410/Str2Split.git seems small and simple enough. Would you be so kind to post the correct hie.yaml
for this project? It has three "targets", as far as I understand - "library", "executable", and "test-suite".
Thanks in advance!
When should "path" point at a directory (like - path: "./test/dispatcher/") and when at a specific file (like - path: "./app/MainHie.hs")
You only provide an exact file match if there is an overlap in components. E.g. the main for the executable is defined in the library.
Could you do me a favor? My sample project https://github.com/mouse07410/Str2Split.git seems small and simple enough. Would you be so kind to post the correct hie.yaml for this project? It has three "targets", as far as I understand - "library", "executable", and "test-suite".
I made a PR
@fendor Thank you!
As your workaround works (thank you!) I'm closing this ticket.
If it's possible to make hie.yaml
support both Cabal and Stack builds on that same project - I'd appreciate if you could post the updated variant here or make another PR.
Thanks again!
If it's possible to make hie.yaml support both Cabal and Stack builds on that same project - I'd appreciate if you could post the updated variant here or make another PR.
No, it isnt
Please open another issue and dont hijack the existing issue!
MacOS Catalina 10.15.4, Xcode-11.4, current
ghcup
that installed GHC 8.8.3 and Cabal-3.2.0.0. Current HIE master, built with Cabal for targethie-8.8.3
.Current VSCode with Haskell Language Server plugin 0.0.37 (and a few more plugins).
I'm trying to add HSpec framework to the tests.
Problem: the very first
import Test.Hspec
is highlighted as an error. See the screenshot:Here's the error message from the "Problems" tab:
You see the complete content of
test/Spec.hs
above. Here'sStr2Split.cabal
:Both Cabal and Stack seem to be able to build both executables
Str2Split-exe
andStr2Split-test
fine, despite the error messages. I can run both of them.If you'd like to see the complete project - please see https://github.com/mouse07410/Str2Split.git
I do not claim that it's a bug - likely a pilot error. But would appreciate any help, please.