Skip to content

Cabal Plugin is too strict for the newest cabal versions #4401

Closed
@fendor

Description

@fendor

Generating a new package with cabal 3.12 via

$ mkdir test-hls-cabal
$ cd test-hls-cabal
$ cabal init --lib -n

Generates a .cabal file with cabal-version: 3.12, which haskell-language-server-2.9.0.1 built with ghc-9.6.5, which is linked against Cabal-3.10.3.0. Consequentially, HLS highlights the whole .cabal file as incorrect, as it doesn't recognise 3.12 as a valid cabal-version.

image

This is bad user-experience.

I am not sure whether we can fix that for good, as older HLS versions will never get linked against a newer Cabal version.
However, what we could do is to be more lenient when it comes to parsing .cabal files.
We can scan the .cabal file for the line cabal-version: (scanSpecVersion) and if the version is not known to us, we parse the cabal file with the newest CabalSpecVersion available to the HLS binary.
The cabal features may still break if users actually need new cabal-the-spec-features, but for many future changes, we likely only display warnings and many other IDE features keep working.

The only real disadvantage is that we can't reliably report incorrect cabal-version numbers any more. Also, the proposed behaviour might be unexpected to users.

The last resort I can think of, is to simply not provide any IDE features if the cabal-version is seemingly too new for the Cabal version linked into HLS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HackathonThis issue is suitable for hackathon sessionscomponent: hls-cabal-pluginIssues related to the hls-cabal-plugintype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions