-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
Ambiguous target if a module belongs to multiple executables. #3507
Comments
Thank you for the bug report! As a work-around, you may extract common modules into an internal library and depend on the internal library. Cabal documentation for internal libraries: https://cabal.readthedocs.io/en/3.8/cabal-package.html?highlight=Internal Libraries#library That, or maintain a cradle:
multi:
- path: ./app/Exp.hs
config:
cradle:
cabal:
component: "exe:exe1"
- path: ./
config:
cradle:
cabal: See hie-bios's documentation for multi cradles for the syntax https://github.com/haskell/hie-bios#multi-cradle |
I created an internal library. However, if I visit the exposed library first from an executable, then there is an error because the internal library is not loaded, yet. If I visit the internal library, then the error goes away. If I visit the internal library first from an executable module, then there is no error. |
What is an error in this context? Some features not working or is HLS outright crashing? |
After I visit
Visiting The executable depends on the internal library and the exposed library. The internal library depends on the exposed library. Thus, if I visit the exposed library from the executable and get back to the executable, there is an error because the internal library is not yet loaded. If I visit the internal library and get back, the error goes away. This error would not occur if haskell-language-server just loads everything from the beginning. |
While this should not be happening, this issue very much different and related to multiple home units. It should be improved with #3480 I think. |
I'm still stuck with GHC 9.0.2 because gentoo linux can't keep up with GHC 9.2.x. I doubt that I will ever have access to GHC 9.6 anytime soon. |
Support for GHC versions that have no native support for multiple home units will always likely be buggy. If this is just a matter of getting your hands on a recent GHC version, use ghcup, it works reliably. |
Does ghcup change GHC version for haskell-language-server on neovim? |
That depends on the neovim plugin, not ghcup. So, I dont know. Also, I just learned that it also works with GHC 9.4, so no need to wait on that patch. |
This is covered by #1370 (and hopefully fixed on recent GHC versions!). |
How is it a duplicate of 1370? It looks very different. |
Your comment #3507 (comment) suggests that the error now is that HLS fails to notice that two types are the same, due to an intermediate component not being loaded. That's what #1370 is also about, and I'm pretty sure it has the same underlying cause. Besides, as @fendor said, this is a completely different error to the one that this thread started with. |
fendor mentioned
The new error occurs with an internal library which is a workaround. The original error occurs without a workaround. I would very much like the original issue to be documented somewhere. The fix for the workaround is captured by 1370. |
I suppose you're right. Sorry. I got carried away and was too keen to close the issue (this project has often suffered from a lot of duplicate/fixed issues, with no one being aggressive enough about closing them...). Although, given what I know about Cabal, I think it's quite likely this will never be fixed. Having a module belong to multiple components is one of those things that's kind-of supported, but in practice doesn't really work. Documentation would be good though, although arguably it belongs in Cabal (maybe even a run-time warning?), not HLS. |
Do we know if the new multiple home units support fixes this, or if the multiple references to the same module remains a problem? |
I think that remains a problem. The proper solution to depend on private sub-libraries, iiuc. |
Your environment
Which OS do you use? Gentoo Linux
Which version of GHC do you use and how did you install it? 9.0.2 from gentoo linux
How is your project built? https://codeberg.org/amano.kenji/brick-tabular-list
Which LSP client (editor/plugin) do you use? nvim-lspconfig
Which version of HLS do you use and how did you install it? 1.9.0.0 from gentoo linux
Have you configured HLS in any way?
hie.yaml
Steps to reproduce
Just open demos/Internal/GridTabularList.hs directly in an editor.
Expected behaviour
No error
Actual behaviour
The text was updated successfully, but these errors were encountered: