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

HLS seems to require a library stanza in the cabal file #3932

Open
Rotaerk opened this issue Jan 6, 2024 · 2 comments
Open

HLS seems to require a library stanza in the cabal file #3932

Rotaerk opened this issue Jan 6, 2024 · 2 comments
Labels
can-workaround component: implicit-hie type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@Rotaerk
Copy link

Rotaerk commented Jan 6, 2024

Environment

OS: NixOS
GHC Version: 9.4.8
Cabal Version: 3.10.2.1
HLS Version: 2.4.0.0

Everything is installed via a nix flake. Here is my project at the time of issue submission: https://github.com/Rotaerk/vulkanSandbox/tree/85d04fd4a834000cb47a7992207f8c74c5028428

What's wrong?

Within the repository root, I run nix develop, which brings cabal, ghc, and HLS among other things into my path. I navigate into the VulkanSandbox directory, and run haskell-language-server-wrapper. When I do, it discovers all 14 of my source files, but fails to load every one, indicating that I need to add them to other-modules or exposed-modules in the cabal file. But they are already there.

The cabal file only has two stanzas: a common and an executable. I noticed that if I change the executable stanza into a library (and removed main-is), suddenly HLS is able to load the source files.

I also noticed that it works if I rename the executable stanza to VulkanSandboxExe, and then add a library stanza to it, such as:

library
  import: common

Note: I tested and confirmed that renaming the executable stanza alone was not enough.

Did I miss something in the HLS documentation about requiring library stanzas?

@Rotaerk Rotaerk added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jan 6, 2024
@fendor
Copy link
Collaborator

fendor commented Jan 6, 2024

Hi, thank you for your bug report!

I haven't checked in detail, but can you report what the behaviour is when you create a hie.yaml file with the contents:

cradle:
  cabal:

in the root of your project?

If this works, then the issue you are encountering is related to implicit-hie, which will be fixed in the next release. If it doesn't work, I will take another look :)

@Rotaerk
Copy link
Author

Rotaerk commented Jan 6, 2024

Yep, adding hie.yaml containing the above to the same folder as my VulkanSandbox.cabal file (after having undone my change to add a library stanza to it) worked. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can-workaround component: implicit-hie 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

2 participants