Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
thisisrandy opened this issue Jan 29, 2023 · 2 comments
Labels
build tool: stack multi-component Issues relating to multi-component support type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@thisisrandy
Copy link

thisisrandy commented Jan 29, 2023

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 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)

Debug information

N/A

@thisisrandy thisisrandy added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jan 29, 2023
@fendor
Copy link
Collaborator

fendor commented Jan 31, 2023

Unfortunately, these are long-standing bugs with the stack/HLS interaction. I dont recall the exact issue, but there are plenty of them.

Fixing this requires closer work with stack maintainers and working out our requirements.

@thisisrandy
Copy link
Author

It sounds like this is unlikely to be fixed in the near future, so I'll emphasize for others that there are workarounds. Among them, the simplest is to close your editor, run stack purge && stack build, and then continue coding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build tool: stack multi-component Issues relating to multi-component support type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants