2

I have happily installed Stack, and run my code with stack ghci or stack exec and whatnot. I would like to use vscode-haskell, and that requires a ghc available in the PATH.

Is it possible to create a ghc command available globally using stack? (e.g. some suitable commans in my powershell/bash profile)

ps. Close duplicates that did not help me are

  1. Using stack ghc as replacement of ghc but only talks about makefiles
  2. Haskell Stack doesn't use system Ghc is about making Stack use a system GHC if it is available which is not the case for me
  3. Haskell stack with global ghc which is close to a dupplicate of [2]
LudvigH
  • 3,662
  • 5
  • 31
  • 49
  • I think vscode-haskell doesn't require ghc if you are working on a stack package, see https://github.com/haskell/vscode-haskell#requirements. So maybe you could just make the code you're working on a stack package? – Noughtmare Jun 30 '21 at 09:45
  • I guess you can configure vscode extension so it looks directly into the folder `stack` has installed ghc, normally somthing like `~/.stack/bin` but it depends on your system. – lsmor Jun 30 '21 at 10:57
  • @Noughtmare yeah that is an option. But I mostly work on small hacker-rank style challenges, so making a project for each seems like a hassle – LudvigH Jun 30 '21 at 12:59
  • @lsmor I can't find any such executable. One often calls `stack ghc` and the GHC call is run through the `stack` executable. Am I searching in the wrong folder? PS. I'm on windows. – LudvigH Jun 30 '21 at 13:05
  • 1
    Another thing that might work is running `stack exec vscode`, then it might get the proper ghc path, but that is just a guess. – Noughtmare Jun 30 '21 at 13:16
  • 1
    try running `stack path`. It will show all paths used by `stack`, including `compiler-exe`. Anyway, even if you are using just for small hacker-rank stuff it would be better to create a project. You can use a different file for each exercise. That would help if you want to use common libraries like `containers` for example – lsmor Jun 30 '21 at 18:24
  • 1
    ah. ok. very nice. found it in `"$env:userprofile\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\bin"`. I could accept that as an answer if you like writing it as such. – LudvigH Jul 01 '21 at 07:34
  • 1
    ...but most likely I'll take your advice on organizing in a stack project. – LudvigH Jul 01 '21 at 07:34

0 Answers0