haskell / haskell/haskell-language-server

Files in app/ directory of stack projects fail to build w/o taking special steps

Open
#3,472 2 comments 2 reactions 0 assignees View on GitHub
build tool: stack multi-component type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
2d 19h
Merged PRs (30d)
11

Description

### Your environment

Which OS do you use?
Ubuntu
Which version of GHC do you use and how did you install it?
9.4.4 / ghcup. Note that issue repros with other supported versions
How is your project built (alternative: link to the project)?
stack defaults. See repro instructions on new stack project below

Which LSP client (editor/plugin) do you use?
neovim + coc.nvim. Repros in VSCode as well
Which version of HLS do you use and how did you install it?
1.9.0.0. As above, other versions repro
Have you configured HLS in any way (especially: a `hie.yaml` file)? No, but see note below

### Steps to reproduce

1. `stack new --resolver nightly-2023-01-28 test`
2. Ensure `ghc-9.4.4` and `HLS-1.9.0.0` are installed
3. Navigate to `./test`
4. Open `app/Main.hs`. Note that an error is issued: `cannot satisfy -package test-0.1.0.0`. If other dependencies are specified in `package.yaml`, it may complain of being unable to satisfy one of those instead.

Some observations that are hopefully clues:
* If `app/Main.hs` is opened first and then `src/Lib.hs`, the same error is displayed at the top of both files. In reverse order, `HLS` works fine on any files in `src` but still fails on files in `app`.
* I've stumbled across several ways to fix the problem. I suspect they're all achieving the same effective result. Make sure to close your editor and run `stack purge` before trying them:
1. Run `stack build`. Open `app/Main.hs` up in an editor. It works! (Sidenote: I do this / `stack run` regularly during development, so I've been seeing this problem disappear "magically" for a while. It was only upon starting a new project today and deciding to dig in and file a bug that I made the connection.)
2. Run `haskell-language-server-wrapper`. This will fail on `Setup.hs` for a default stack project, but we can just ignore that. This seems like a clue that `haskell-language-server-wrapper` is doing something different build-wise when run with `--lsp` vs. without.
3. Make a simple `hie.yaml`, i.e. `cradle:\n stack:`. Same result. This could be a clue that [implicit-hie](https://github.com/Avi-D-coder/implicit-hie) is being used strangely (or itself has a bug).

### Expected behaviour

Everything works without taking any of the steps detailed above.

### Actual behaviour

(Covered in [Steps to reproduce](#steps-to-reproduce))

### Debug information

N/A

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.