Skip to content

"Could not load module ‘Distribution.Simple’" for Setup.hs #335

@jasagredo

Description

@jasagredo

Setup

I have a setup with multi cradle setup that aggregates several projects together, some of which are stack projects and other are cabal projects (but for the case being, we could consider all of them as stack projects). My hie.yaml file looks like this:

cradle:
  stack:
    - path: "/full/path/to/project1"
      component: "project1:lib"
    - path: "/full/path/to/project1/app"
      component: "project1:exe:project1-exe"
    - path: "/full/path/to/project2"
      component: "project2:lib"
    - path: "/full/path/to/project2/app"
      component: "project2:exe:project2-exe"
...

Errors

Running haskell-language-server-wrapper -d -l /tmp/hie.log throws errors on the Setup.hs files of those projects. The errors are like these:

Simple Setup.hs files

File:     /full/path/to/project1/Setup.hs
Hidden:   no
Range:    1:7-1:26
Source:   not found
Severity: DsError
Message: 
  Could not load module ‘Distribution.Simple’
  It is a member of the hidden package ‘Cabal-3.0.1.0’.
  You can run ‘:set -package Cabal’ to expose it.
  (Note: this unloads all the modules in the current scope.)

with the Setup.hs file just being a simple distribution file:

import Distribution.Simple
main = defaultMain

and having the build-type of the package set to Simple in the package.yaml file.

More complex Setup.hs examples (with directory)

In more complex Setup.hs files, other modules seem to be missing:

File:     /full/path/to/project2/Setup.hs
Hidden:   no
Range:    7:7-7:23
Source:   not found
Severity: DsError
Message: 
  Could not load module ‘System.Directory’
  It is a member of the hidden package ‘directory-1.3.6.0’.
  You can run ‘:set -package directory’ to expose it.
  (Note: this unloads all the modules in the current scope.)

with the following config in the .cabal file:

Build-Type:     Custom

custom-setup
  setup-depends:
    base  >= 4.7,
    Cabal >= 2.2,
    directory >= 1.3

Expected behavior

I thought those files could also be checked by HLS and if not, I expected them to be directly ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    can-workaroundcomponent: hie-biostype: 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