Closed tomseli closed 1 week ago
Hi, thank you for your bug report!
process
and directory
are packages that you need to actively depend on in a cabal project. They are included by default if you just use ghc
, but with .cabal files you need to be explicit :)
executable Hac-Man
import: warnings
main-is: Main.hs
other-modules: Controller.Controller,
View.View,
Model.Model
build-depends: base ^>=4.17.2.1,
gloss ^>=1.13.0.4,
directory,
process
hs-source-dirs: src
default-language: Haskell2010
BTW, cabal build
should show you the same error message.
PS, here is the documentation for directory
and process
. Often, when you are using directory
, you also want filepath
. So maybe you also want to depend on filepath
in the future.
Thanks for the quick response!
I've edited the build-depends as you sugested, then rebuilt the project. Cabal build does not give me any warnings whatsoever.
Unfortunately, I get the same error from HLS.
Do you have any further ideas? Do you need more information?
Have you restarted the editor? Unfortunately, HLS does not pick up changes to the .cabal file automatically due to some bugs.
Otherwise, please show the new logs of vscode.
Oh wait, I may have misidentified the problem
This seems to be an issue in hie-bios
, we fail to compile the wrapper.hs
which is necessary to launch HLS correctly...
This looks more complicated than anticipated. Have you ever run cabal install --lib
by accident or purpose?
Can you reproduce the error message via running ghc "-rtsopts=ignore" "-outputdir" "C:\\Users\\tomse\\AppData\\Local\\Temp\\hie-bios-d70021ae70e1c91c" "-o" "C:\\Users\\tomse\\AppData\\Local\\hie-bios\\wrapper-340ffcbd9b6dc8c3bed91eb5c533e4e3.exe" "C:\\Users\\tomse\\AppData\\Local\\hie-bios\\wrapper-340ffcbd9b6dc8c3bed91eb5c533e4e3.hs"
?
I can indeed replicate the error running that code. And I likely have ran cabal install --lib
at some point.
For completeness sake, here's the full error:
PS C:\Repositories\Hac-Man> ghc "-rtsopts=ignore" "-outputdir" "C:\\Users\\tomse\\AppData\\Local\\Temp\\hie-bios-d70021ae70e1c91c" "-o" "C:\\Users\\tomse\\AppData\\Local\\hie-bios\\wrapper-340ffcbd9b6dc8c3bed91eb5c533e4e3.exe" "C:\\Users\\tomse\\AppData\\Local\\hie-bios\\wrapper-340ffcbd9b6dc8c3bed91eb5c533e4e3.hs"
Loaded package environment from C:\Users\tomse\AppData\Roaming\ghc\x86_64-mingw32-9.4.8\environments\default
[1 of 2] Compiling Main ( C:\\\\Users\tomse\AppData\Local\hie-bios\wrapper-340ffcbd9b6dc8c3bed91eb5c533e4e3.hs, C:\\\\Users\tomse\AppData\Local\Temp\hie-bios-d70021ae70e1c91c\Main.o )
C:\\\\Users\tomse\AppData\Local\hie-bios\wrapper-340ffcbd9b6dc8c3bed91eb5c533e4e3.hs:4:1: error:
Could not load module `System.Directory'
It is a member of the hidden package `directory-1.3.7.1'.
You can run `:set -package directory' to expose it.
(Note: this unloads all the modules in the current scope.)
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
4 | import System.Directory (getCurrentDirectory)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
C:\\\\Users\tomse\AppData\Local\hie-bios\wrapper-340ffcbd9b6dc8c3bed91eb5c533e4e3.hs:7:1: error:
Could not load module `System.Process'
It is a member of the hidden package `process-1.6.24.0'.
You can run `:set -package process' to expose it.
(Note: this unloads all the modules in the current scope.)
It is a member of the hidden package `process-1.6.18.0'.
You can run `:set -package process' to expose it.
(Note: this unloads all the modules in the current scope.)
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
7 | import System.Process (spawnProcess, waitForProcess)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Perfect, that solves the issue!
So, unless you know what you are doing, it is safe to say you should never run cabal install --lib
. It was a bad idea by cabal to suggest it, it is almost never what you really want.
If you want to play around with packages in ghci, prefer cabal repl -z -b <name-of-package>
.
Please delete the file C:\Users\tomse\AppData\Roaming\ghc\x86_64-mingw32-9.4.8\environments\default
, then everything should be fine.
Perfect! That did it. Thanks for the help!
Happy hacking! Feel free to open more issues if you encounter any more problems!
Your environment
Which OS do you use?
Windows 11
Which version of GHC do you use and how did you install it?
The GHCup Haskell installer, version 0.1.30.0 cabal-install version 3.12.1.0 compiled using version 3.12.1.0 of the Cabal library
How is your project built (alternative: link to the project)? Using Cabal, with the following .cabal file
Which LSP client (editor/plugin) do you use?
VSCode + Haskell extensions
Which version of HLS do you use and how did you install it? Got prompted by the extension ghcup install hls reports hls-2.9.0.1
Have you configured HLS in any way (especially: a
hie.yaml
file)?What's wrong?
HLS fails to start in my cabal project. It does work in other (non-project) Haskell files.
It reports a hidden package (directory and process). I've messed around with the paths (currently it's back to default), and tried to install those packages, even though they clearly are installed. I've browsed the issues and the docs, and found no mention of this error. I'm at my wits end to get it to work, so some help would be very appreciated!
NB the project builds and runs without issues.
Debug information
The output from VSCode: