r/haskellquestions • u/peroama • May 07 '23
Using VSCode with Haskell and stack
I learn/write Haskell in VSCode with the "Haskell for Visual Studio Code"-plugin (provides hls support for VSCode) on Windows.
On its own it works perfectly fine but now I am trying to create my first project using stack and this stops hls from working.
Starting a new project with stack works fine:
stack new testin the folder test run
stack build
But then hls has two problems:
in src/Lib.hs
Failed to parse result of calling stack
[0mConfiguring GHCi with the following packages: test[0m
[0mC:\Users\jbitterlich\AppData\Local\hie-bios\wrapper-340ffcbd9b6dc8c3bed91eb5c533e4e3.exe: startProcess: permission denied (Permission denied)[0mand in test/Spec.hs:
Failed to parse result of calling stack
[0mUsing main module: 1. Package `test' component test:test:test-test with main-is file: C:\Users\jbitterlich\github\haskell_projects\test\test\Spec.hs[0m
[0mtest> configure (lib + test)[0m
[0mConfiguring test-0.1.0.0...[0m
[0mtest> initial-build-steps (lib + test)[0m
[0mtest> Test running disabled by --no-run-tests flag.[0m
[0mCompleted 2 action(s).[0m
[0mThe following GHC options are incompatible with GHCi and have not been passed to it: -threaded[0m
[0mConfiguring GHCi with the following packages: test[0m
[0mC:\Users\jbitterlich\AppData\Local\hie-bios\wrapper-340ffcbd9b6dc8c3bed91eb5c533e4e3.exe: startProcess: permission denied (Permission denied)[0mI found this question online that seems to be related, but I am too much overwhelmed right now by cabal, stack, ghcup that I don't know what to do with this information:https://stackoverflow.com/questions/73155847/using-vscode-with-haskell-ghcup-and-stack-hls-crashes-with-newer-versions-of
2
u/Anrock623 May 07 '23
If stack isn't absolutely necessary it's better to use cabal and install ghc via ghcup
2
u/peroama May 08 '23
Yeah, I had problems with stack before. So I gave cabal a try. Following https://www.haskell.org/cabal/ I run
cabal initand thencabal rungreets me with this error:
$ cabal run
Resolving dependencies...
Build profile: -w ghc-9.2.7 -O1
In order, the following will be built (use -v for more details):
- test3-0.1.0.0 (exe:test3) (first run)
Configuring executable 'test3' for test3-0.1.0.0..
Preprocessing executable 'test3' for test3-0.1.0.0..
Building executable 'test3' for test3-0.1.0.0..
[1 of 1] Compiling Main ( app\Main.hs, C:\\Users\jbitterlich\github\haskell_projects\test3\dist-newstyle\build\x86_64-windows\ghc-9.2.7\test3-0.1.0.0\x\test3\build\test3\test3-tmp\Main.o )
Linking C:\\Users\\jbitterlich\\github\\haskell_projects\\test3\\dist-newstyle\\build\\x86_64-windows\\ghc-9.2.7\\test3-0.1.0.0\\x\\test3\\build\\test3\\test3.exe ...
C:\Users\jbitterlich\github\haskell_projects\test3\dist-newstyle\build\x86_64-windows\ghc-9.2.7\test3-0.1.0.0\x\test3\build\test3\test3: createProcess: permission denied (Permission denied)At least I think that's an error :D
2
u/Anrock623 May 09 '23
Sorry, I'm not a Windows expert.
Could it be that for some reason you don't have execution permissions in that directory? Does it launch if you're executing that test3 binary manually? It doesn't seem to be an issue with tooling per se.
2
u/peroama May 10 '23
I tried to run in manually and it didn't work either. But then I built it again and everything works :D
Hope it's going to stay that way.
Thank you a lot!
2
1
0
May 07 '23
[removed] — view removed comment
2
u/AlexKingstonsGigolo May 08 '23
Are you okay?
1
2
u/friedbrice May 07 '23
Are you using the official version of Stack that comes with GHC Up? When you installed Stack (using GHC Up, of course) did you say "Yes" to Stack/GHC Up integration? Make sure you've done those two steps. That's all i got for you :-/ Good luck.