haskell / haskell/haskell-language-server

Local compiler plugin cannot be loaded in ghcide even with `-fobject-code`

Open
#730 1 comment 1 reaction 0 assignees View on GitHub
component: ghcide type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
2d 19h
Merged PRs (30d)
11

Description

This was originally reported as haskell/haskell-language-server#70, but it turns out that this is a bug in ghcide, so I re-open the issue here.

### Subject of the issue
If one specifies GHC's compiler plugin provided in the *same* package, ghcide fails to find the plugin module.

### Your environment
* ghcide HEAD (10dbde048e8ac028e80f607445776c8375722f75)
* VSCode
* Describe your project: You can use the [same repro repo](/konn/hls-repro) as reported on hls.
* hie.yaml: Provided above.

### Steps to reproduce
1. Set the Languager Server path to the ghcide.
2. Open the src/Lib.hs in the editor.

### Expected behaviour
ghcide should work properly and no bugs must be reported, as `-fobject-code` flag is properly detected by hie-bios.

### Actual behaviour
`Lib` module gets the following error:

```
{
"resource": "/Users/hiromi/Documents/Programming/Haskell/git/hls-repro/src/Lib.hs",
"owner": "Haskell (hls-repro)",
"severity": 8,
"message": "Unexpected usage error\nCould not load module ‘Lib.Plugin’\nIt is a member of the hidden package ‘hls-repro-0.1.0.0’.\nPerhaps you need to add ‘hls-repro’ to the build-depends in your .cabal file.\n",
"source": "pragmas",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 2,
"endColumn": 1
}
```

(Note that the error message has changed since the first report)

### Possible cause
It seems that the cause of this behaviour is the lack of dependency information in `HsEnv` value obtained in `getModSummaryRule`, which is finally passed to `Development.IDE.Core.Preprocessor.preprocess`.
I once tried to expand the definition of `GhcSessionDeps` definition into `getModSummaryRule`, but it won't work since the core logic contains the call for `GetModSummaryWithoutTimestamps`, which eventually calls `GetModSummary`, resulting in cyclic dependency and ghcide stuck in the infinite loop.

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.