Skip to content

'Couldn't figure out what GHC version the project is using' error on Windows 10 #435

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

Closed
MuratOzsoyler opened this issue Aug 14, 2021 · 5 comments · Fixed by #439
Closed
Labels
os: windows Windows related issues type: bug A bug or unintended effect

Comments

@MuratOzsoyler
Copy link

I'm getting this error every time I open a project folder:

Couldn't figure out what GHC version the project is using: c:\Users\zmtemp\AppData\Roaming\Code - Insiders\User\globalStorage\haskell.haskell\haskell-language-server-wrapper-1.3.0-win32.exe --project-ghc-version exited with exit code 1: 'c:\Users\zmtemp\AppData\Roaming\Code' is not recognized as an internal or external command, operable program or batch file.

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

> & 'C:\Users\zmtemp\AppData\Roaming\Code - Insiders\User\globalStorage\haskell.haskell\haskell-language-server-wrapper-1.3.0-win32.exe' --probe-tools
haskell-language-server version: 1.3.0.0 (GHC: 8.10.4) (PATH: C:\Users\zmtemp\AppData\Roaming\Code - Insiders\User\globalStorage\haskell.haskell\haskell-language-server-wrapper-1.3.0-win32.exe) (GIT hash: e7c5e90b6df5dff2760d76169eddaea3bdd6a831)  
Tool versions found on the $PATH
cabal:          Not found       
stack:          2.7.1
ghc:            8.6.5

Which OS do you use:
Windows 10 Pro 21H1 19043.1151
Which lsp-client do you use:
VSCode Insiders
Describe your project (alternative: link to the project):
stack.yaml :

resolver: lts-14.27
packages:
- .

sheytan-generate.cabal :

cabal-version: >=1.10
name: sheytan-generate
version: 0.1.0.0
license: BSD3
license-file: LICENSE
copyright: 2020 Author name here
maintainer: [email protected]
author: Author name here
homepage: https://github.com/githubuser/sheytan-generate#readme
category: Web
build-type: Simple
extra-source-files:
    README.md

executable sheytan-generate
    main-is: Main.hs
    hs-source-dirs: src
    other-modules:
        Types
    default-language: Haskell2010
    build-depends:
        base >=4.7 && <5,
        directory -any,
        extra -any,
        regex-applicative -any

Contents of hie.yaml:
No hie.yaml

Steps to reproduce

Just open the project folder and wait for the extension activated. A notification appeared.

Expected behaviour

Extensions supposed to exceute appropirately!

Actual behaviour

I suspect that the space in the Code - Insiders\ directory prevents the relevant command to be executed.

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

Debug output:
& 'C:\Users\zmtemp\AppData\Roaming\Code - Insiders\User\globalStorage\haskell.haskell\haskell-language-server-wrapper-1.3.0-win32.exe' --debug
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper-1.3.0-win32.exe) Version 1.3.0.0, Git revision e7c5e90b6df5dff2760d76169eddaea3bdd6a831 (dirty) x86_64 ghc-8.10.4
Current directory: C:\Users\zmtemp\Desktop\haskell\projects\sheytan-generate
Operating system: mingw32
Arguments: ["--debug"]
Cradle directory: C:\Users\zmtemp\Desktop\haskell\projects\sheytan-generate
Cradle type: Stack

Tool versions found on the $PATH
cabal:          Not found
stack:          2.7.1
ghc:            8.6.5


Consulting the cradle to get project GHC version...
Project GHC version: 8.6.5
haskell-language-server exe candidates: ["haskell-language-server-8.6.5.exe","haskell-language-server.exe"]
Cannot find any haskell-language-server exe, looked for: haskell-language-server-8.6.5.exe, haskell-language-server.exe

Paste the logs from the lsp-client, e.g. for VS Code

LSP logs:
<paste your logs here>
@Ailrun
Copy link
Member

Ailrun commented Aug 14, 2021

Thank you for leaving an issue. It looks like your haskell-language-server-wrapper cannot find a correct version of HLS binary in your system. How did you install HLS? As you want to use lts-14.27, you probably need haskell-language-server-8.6.5.exe in your %PATH%.

@MuratOzsoyler
Copy link
Author

Thank you for your answer.

Note that the critical point is, I think, the extension (or whatever code it is) can not excecute the command c:\Users\zmtemp\AppData\Roaming\Code - Insiders\User\globalStorage\haskell.haskell\haskell-language-server-wrapper-1.3.0-win32.exe --project-ghc-version when initializing. The error message is c:\Users\zmtemp\AppData\Roaming\Code' is not recognized as an internal or external command, operable program or batch file.

The mentioned executable is in the disk and in the right path by the way. I also think that, the command is executed under another shell and is not quoted properly, as the command is truncated at the first space character. This is clearly a minor bug.

@jneira jneira transferred this issue from haskell/haskell-language-server Aug 15, 2021
@jneira
Copy link
Member

jneira commented Aug 15, 2021

@MuratOzsoyler you are right, the vscode extension is the responsible of make that call and the bug is here (i've transferred the issue to the extesion repo)

The code is here:

const childProcess = child_process
.execFile(
wrapper,
args,
{ encoding: 'utf8', cwd: dir, shell: getGithubOS() === 'Windows' },
(err, stdout, stderr) => {

I recently made the call inside a shell to being able to call .cmdand .bat script, but probably that makes the call fail if the path is not quoted, as you suspected.

So we have to confirm executing inside the shell is the cause and set to false or quote the PATH. Quoting could be tricky and we'll have take in account corner cases.

@jneira jneira added os: windows Windows related issues type: bug A bug or unintended effect labels Aug 15, 2021
@MuratOzsoyler
Copy link
Author

Thank you for transferring the issue to the appropriate issue tracker. I recently figured out that, located the same source file and will attempt to open an issue in the vscode extension repo.

@jneira
Copy link
Member

jneira commented Aug 15, 2021

just in case this issue is already in the vscode extension issue tracker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os: windows Windows related issues type: bug A bug or unintended effect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants