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

Error: setup: can't find source for <module> in ... #3803

Closed
benz0li opened this issue Sep 11, 2023 · 5 comments
Closed

Error: setup: can't find source for <module> in ... #3803

benz0li opened this issue Sep 11, 2023 · 5 comments
Labels
status: needs triage type: support User support tickets, questions, help with setup etc.

Comments

@benz0li
Copy link

benz0li commented Sep 11, 2023

Your environment

This issue can be reproduced with the default Dev Container at https://github.com/benz0li/commercialhaskell-stack/tree/add-dev-containers

Which OS do you use?

Alpine Linux/AArch64

Which version of GHC do you use and how did you install it?

Unofficial build of GHC v9.4.6: 9.4.6.Dockerfile

Which LSP client (editor/plugin) do you use?

VS Code + vscode-haskell

Which version of HLS do you use and how did you install it?

Unofficial build of HLS v2.1.0.0: 2.1.0.0.Dockerfile

ℹ️ Put together in a Dev Container based on devcontainer.json + GHC.Dockerfile

Tool versions found on the $PATH
cabal:          3.8.1.0
stack:          2.11.1
ghc:            9.4.6

Have you configured HLS in any way (especially: a hie.yaml file)?

Yes: hie.yaml

What's wrong?

Last step: Opening src/Stack.hs: Haskell extension > View Problem:
(other steps: see below)

Failed to run ["cabal","v2-repl","lib:stack"] in directory "/workspaces/stack". Consult the logs for full command and error.
Failed command: cabal --builddir=/home/vscode/.cache/hie-bios/dist-stack-7d4030fb4073a5f963b4594938e6876d v2-repl --with-compiler /home/vscode/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/vscode/.cache/hie-bios/ghc-pkg-2e9e7382b10dc1de912243f849341f70 lib:stack
Build profile: -w ghc-9.4.6 -O1
In order, the following will be built (use -v for more details):
 - stack-2.12.0 (first run)
[1 of 2] Compiling Main             ( /home/vscode/.cache/hie-bios/dist-stack-7d4030fb4073a5f963b4594938e6876d/build/aarch64-linux/ghc-9.4.6/stack-2.12.0/setup/setup.hs, /home/vscode/.cache/hie-bios/dist-stack-7d4030fb4073a5f963b4594938e6876d/build/aarch64-linux/ghc-9.4.6/stack-2.12.0/setup/Main.o )
[2 of 2] Linking /home/vscode/.cache/hie-bios/dist-stack-7d4030fb4073a5f963b4594938e6876d/build/aarch64-linux/ghc-9.4.6/stack-2.12.0/setup/setup
Configuring stack-2.12.0...
Preprocessing library for stack-2.12.0..

Error: setup: can't find source for Build_stack in src, src/unix/,
/home/vscode/.cache/hie-bios/dist-stack-7d4030fb4073a5f963b4594938e6876d/build/aarch64-linux/ghc-9.4.6/stack-2.12.0/build/autogen,
/home/vscode/.cache/hie-bios/dist-stack-7d4030fb4073a5f963b4594938e6876d/build/aarch64-linux/ghc-9.4.6/stack-2.12.0/build/global-autogen

Error: cabal: repl failed for stack-2.12.0.



Process Environment:
HIE_BIOS_GHC: /usr/local/lib/ghc-9.4.6/bin/ghc-9.4.6
HIE_BIOS_GHC_ARGS: -B/usr/local/lib/ghc-9.4.6/lib

Debug information

Steps according to https://github.com/benz0li/commercialhaskell-stack/tree/add-dev-containers/.devcontainer#cabal:

Cabal

Place the cradle (hie.yaml) for Cabal in the root of the workspace: cp -f .devcontainer/assets/cradles/cabal/hie.yaml .

Command cabal build once. cabal build causes Cabal (the library) to create the automatically generated module Stack_build.

cabal_build.log

ℹ️ cabal repl works, too:

cabal_repl.log

Haskell extension

Now, you can install and use the Haskell extension.

Choose Manually via PATH when asked the following question:

manageHLS

Opening src/Stack.hs: haskell-extension.log

@benz0li benz0li added status: needs triage type: support User support tickets, questions, help with setup etc. labels Sep 11, 2023
@benz0li
Copy link
Author

benz0li commented Sep 11, 2023

cabal repl knows where to look: /workspaces/stack/dist-newstyle/build/aarch64-linux/ghc-9.4.6/stack-2.12.0/build/global-autogen/Build_stack.hs

cabal (HLS) does not: /home/vscode/.cache/hie-bios/dist-stack-7d4030fb4073a5f963b4594938e6876d/build/aarch64-linux/ghc-9.4.6/stack-2.12.0/build/global-autogen

@benz0li
Copy link
Author

benz0li commented Sep 11, 2023

P.S.: Using Stack + this hie.yaml works fine.

Cross reference: commercialhaskell/stack#6228 (comment)

@mpilgrem
Copy link

@benz0li, I think I have an answer for the Stack project: its custom ./Setup.hs defines a buildHook that creates the auto-generated module but does not define a corresponding replHook. If I add a corresponding replHook, HLS seems to be satisfied. (Now, I need also to satisfy myself that doing so does not break something else, somewhere else.)

@fendor
Copy link
Collaborator

fendor commented Sep 12, 2023

@mpilgrem your analysis is exactly correct and I did a similar fix for cabal's testsuite a couple of weeks ago.

@michaelpj
Copy link
Collaborator

Sounds like you've figured this out. Feel free to reopen if it looks like a HLS issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage type: support User support tickets, questions, help with setup etc.
Projects
None yet
Development

No branches or pull requests

4 participants