haskell / haskell/haskell-language-server

HLS seems to require a library stanza in the cabal file

Open
#3,932 2 comments 0 reactions 0 assignees View on GitHub
can-workaround component: implicit-hie type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
2d 19h
Merged PRs (30d)
11

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.