Couldn't figure out what GHC version the project is using

vscode+ haskell extension on endeavour os kde with stack cabal and ghc configured and in $PATH

/snap/bin:/home/qwerty/.nimble/bin:/root/.local/share/gem/ruby/3.0.0/bin:/home/qwerty/.gem/ruby/3.0.0/bin:/home/qwerty/.gem/ruby/2.7.0/bin:/home/qwerty/clones/bat-extras/bin:/home/dankey/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:/usr/bin/cabal:/usr/bin/stack:/usr/bin/ghc:/usr/bin/cabal:/usr/bin/stack:/usr/bin/ghc:/home/qwerty/.gem/ruby/2.7.0/bin

with hie.yaml looking like

cradle:
  stack:

on a brand new stack project
the extension (hls) fails with this error:

Couldn't figure out what GHC version the project is using: /home/dankey/.config/Code/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-1.4.0-linux --project-ghc-version exited with exit code 1: Found "/home/dankey/dev/projects/bla/hie.yaml" for "/home/dankey/dev/projects/bla/a" Failed to get project GHC version:CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitFailure 1, cradleErrorStderr = ["Error when calling stack setup --silent","",""]}

this is the output from the haskell section on the output tab

[client][ERROR] Error executing '/home/dankey/.config/Code/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-1.4.0-linux --project-ghc-version' with error code 1
[client][ERROR] stderr: Found "/home/dankey/dev/projects/bla/hie.yaml" for "/home/dankey/dev/projects/bla/a"
Failed to get project GHC version:CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitFailure 1, cradleErrorStderr = ["Error when calling stack setup --silent","",""]}

help

Do you have a stack.yaml file? If so, what are its contents? Does running stack repl work?

yes. i initialized the proj with stack new bla: https://pastebin.com/TKPh1uKt

stack repl does work. however it does state the warning:

* * * * * * * *

Warning: Multiple files use the same module name:
         * Paths_bla found at the following paths
           * /home/dankey/dev/projects/bla/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/autogen/Paths_bla.hs (bla:lib)
           * /home/dankey/dev/projects/bla/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/bla-exe/autogen/Paths_bla.hs (bla:exe:bla-exe)
* * * * * * * *

The error messages seem to mention a file /home/dankey/dev/projects/bla/a, does that exist as a file or directory? I don’t think it is part of the standard stack new template.

nope

[dankey@locally ~/dev/projects/bla]$ ls /home/dankey/dev/projects/bla/a
ls: cannot access '/home/dankey/dev/projects/bla/a': No such file or directory

SOLVED
i reinstalled, this time with ghcup and put exactly, and only ~/.ghcup/bin in $PATH

1 Like

Just for future reference, I think this might be related to your problem: From in your $PATH you had

…:/usr/bin/cabal:/usr/bin/stack:/usr/bin/ghc:…

but note that $PATH should refer to directories, not executables. I’m guessing something might have become confused at seeing executables mentioned directly like that. (Just having /usr/bin in PATH would be sufficient to find both “cabal” and “ghc”, FWIW.)

1 Like

For further future reference, the filepath a within your project is a dummy filepath. It is solely used for finding the cradle type (e.g. stack/cabal or direct or shell) and carries no meaning. It is always the first question of hls what the cradle type and ghc version is, but until you have opened a real file, it can’t really know. Thus, we supply a fake filepath that only used for establishing the project root.

1 Like