Skip to content
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

Working out the project GHC version seemingly never finishes #421

Closed
Savelenko opened this issue Aug 4, 2021 · 24 comments · Fixed by #422
Closed

Working out the project GHC version seemingly never finishes #421

Savelenko opened this issue Aug 4, 2021 · 24 comments · Fixed by #422
Assignees
Labels
type: bug A bug or unintended effect

Comments

@Savelenko
Copy link

After automatic update to 1.5.0 VS Code (OSS Code 1.55.2) shows a new status "Working out the project GHC version. This might take a while...". I've read a bit that this used to fail to appear without clear progress indication to the user but in my case it never finishes (I restarted VS Code several times and waited for ~10 minutes). Consequently, HLS never starts and there is no debug output under Haskell.

Just yesterday, before the update my whole set-up worked great, the only change is 1.5.0 of the extension. Here is my HLS environment:

~/.config/Code\ -\ OSS/User/globalStorage/haskell.haskell/haskell-language-server-1.3.0-linux-8.8.4 --probe-tools
haskell-language-server version: 1.3.0.0 (GHC: 8.8.4) (PATH: /home/yos/.config/Code - OSS/User/globalStorage/haskell.haskell/haskell-language-server-1.3.0-linux-8.8.4) (GIT hash: e7c5e90b6df5dff2760d76169eddaea3bdd6a831)
Tool versions found on the $PATH
cabal:		2.4.1.0
stack:		2.5.1
ghc:		Not found
@gboduljak
Copy link

I have the same problem.

@gboduljak
Copy link

Downgrading to the previous version of the extension solves the problem.

@Savelenko
Copy link
Author

Savelenko commented Aug 4, 2021

What is the version you downgraded to? I was hesitant to do so because 1.3.0 and 1.4.0 seem to exist, but VS Code suggests only 1.2.0 as previous version.

Actually, after upgrading VS Code to 1.58 the "Install another version" option became disabled and there is no way of restoring a working environment.

@Savelenko
Copy link
Author

Savelenko commented Aug 4, 2021

I took a look at what should happen in the source code and running manually the following works:

$ ~/.config/Code\ -\ OSS/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-1.3.0-linux --project-ghc-version
Found "/home/yos/<...>/hie.yaml" for "/home/yos/<...>/a"
8.8.4

@gboduljak
Copy link

1.4.0 is the one I downgraded to after downgrading VS Code :). Thanks for the feedback.

@Savelenko
Copy link
Author

Savelenko commented Aug 4, 2021

Additional observations. When manually running the non-wrapper binary, much more output is produced and in the end an error is reported:

$ ~/.config/Code\ -\ OSS/User/globalStorage/haskell.haskell/haskell-language-server-1.3.0-linux-8.8.4 --project-ghc-version
....
2021-08-04 11:30:49.773631364 [ThreadId 198] INFO hls:	File:     /home/yos/<...>/backend/Setup.hs
Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: /home/yos/<...>/backend
  filepath: /home/yos/<...>/backend/Setup.hs
  prefixes:
  ("./src",Stack {component = Just "ttb:lib", stackYaml = Nothing})
  ("./app",Stack {component = Just "ttb:exe:ttb-exe", stackYaml = Nothing})
  ("./test",Stack {component = Just "ttb:test:ttb-test", stackYaml = Nothing})
2021-08-04 11:30:52.28346358 [ThreadId 197] INFO hls:	finish: User TypeCheck (took 4.84s)
2021-08-04 11:30:52.350956689 [ThreadId 198] INFO hls:	finish: GetHie (took 0.07s)
Files that failed:
 * /home/yos/<...>/backend/Setup.hs

2021-08-04 11:30:52.614362533 [ThreadId 1531] INFO hls:	finish: GenerateCore (took 0.26s)
Completed (72 files worked, 1 file failed)

My hie.yaml file looks like this:

cradle:
  stack:
    - path: "./src"
      component: "ttb:lib"
    - path: "./app"
      component: "ttb:exe:ttb-exe"
    - path: "./test"
      component: "ttb:test:ttb-test"

Given that manually running the wrapper seems to do more than the non-wrapper binary, I tried manually setting the executable path to it (and to the non-wrapper) but VS Code shows an error pop-up with

serverExecutablePath is set to /home/yos/.config/Code\ -\ OSS/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-1.3.0-linux but it doesn't exist and is not on the PATH

In the past I used to change this setting like this and this error is new and surprising to me.

Finally, I tried deleting Setup.hs completely but that did not have any effect.

@jneira jneira added the type: bug A bug or unintended effect label Aug 4, 2021
@jneira jneira self-assigned this Aug 4, 2021
@jneira
Copy link
Member

jneira commented Aug 4, 2021

Hi, sorry for the incoveniences, i'll try to fix the code introduced in #414 and revert the change if it is not possible to do it in a reasonable amount of time.
I've checked that error handling is not working correctly and killing the hls executable while working out the ghc version makes the progress notification hangs.
But i checked locally that it worked when the process ended succesfully, to investigate.

@jneira
Copy link
Member

jneira commented Aug 4, 2021

But i checked locally that it worked when the process ended succesfully, to investigate.

Just tried again and works for me in windows

@Savelenko
Copy link
Author

Savelenko commented Aug 4, 2021

Just tried again and works for me in windows

Do I understand correctly that the happy flow works, but error handling (at least under Linux) does not?

@jneira
Copy link
Member

jneira commented Aug 4, 2021

Yeah, that is my impression, however, error handling apart, i used a way to spawn the subprocess that uses a shell by default and maybe it could be the cause of your issue (afaiu the process of getting ghc version works for you)

@jneira
Copy link
Member

jneira commented Aug 4, 2021

@Savelenko @gboduljak hi, i've made a pr to try to fix the issue, coud you have the chance of trying it locally to see if it really fixes the issue for you? If it makes easier the testing i could upload a .vsix file installable from vscode.

@Savelenko
Copy link
Author

I'd gladly test it if you could provide a .vsix file or provide an alternative instruction. I have no experience of hacking around with VS Code like this.

@jneira
Copy link
Member

jneira commented Aug 4, 2021

@Savelenko many thanks, you could download the vsix file here: https://github.com/haskell/vscode-haskell/releases/download/1.5.0/haskell-1.5.1-beta.vsix
Then you can install the extension from a vsix file in Extensions -> Views and more actions... (... in the right up corner) -> Instal from VSIX...

The command can be found in the command palette: workbench.extensions.action.installVSIX

@Savelenko
Copy link
Author

Thanks, I could install it and after reloading the following error popped up immediately:

Couldn't figure out what GHC version the project is using: /home/yos/.config/Code - OSS/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-1.3.0-linux --project-ghc-version exited with exit code ENOENT:

I am ready to test as many times as needed :)

@jneira
Copy link
Member

jneira commented Aug 4, 2021

Hmm i've observed the path to the executable contains spaces /home/yos/.config/Code - OSS/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-1.3.0-linux and it might be the cause ( see https://stackoverflow.com/questions/10941545/nodejs-child-process-spawn-does-not-work-when-one-of-the-args-has-a-space-in-it), working on it

@jneira
Copy link
Member

jneira commented Aug 4, 2021

Ok, i've uploaded a new beta version: https://github.com/haskell/vscode-haskell/releases/download/1.5.0/haskell-1.5.1-beta-2.vsix
@Savelenko i hope it will be the final one 🙂

@Savelenko
Copy link
Author

Yes, this solved it, thanks a lot! By the way, the spaces in Code - OSS is the standard VS Code installation path at least in Manjaro Linux so I imagine more users could encounter this problem.

@jneira
Copy link
Member

jneira commented Aug 4, 2021

Nice!, many thanks again
Will release the new version asap thanks for noting the default path is triggering the bug.

jneira added a commit that referenced this issue Aug 4, 2021
- Add much more logging in the client side, configured with haskell.trace.client
- Fix error handling of working out project ghc (See #421)
  - And dont use a shell to spawn the subprocess in non windows systems
- Add commands Start Haskell LSP server and Stop Haskell LSP server
@AZMCode
Copy link

AZMCode commented Jul 31, 2022

Having this problem again with an OpenSUSE installation. GHCup freshly installed, Extension too, on a brand new stack project.

Extension Logs as following:

2022-07-31 14:35:58.2430000 [client] INFO Finding haskell-language-server
2022-07-31 14:35:58.2460000 [client] INFO Checking for ghcup installation
2022-07-31 14:35:58.2950000 [client] INFO found ghcup at ghcup
2022-07-31 14:35:58.2980000 [client] INFO Executing 'ghcup --no-verbose list -t hls -c installed -r' in cwd '<project root>'
2022-07-31 14:35:59.1450000 [client] INFO Checking for ghcup installation
2022-07-31 14:35:59.1550000 [client] INFO found ghcup at ghcup
2022-07-31 14:35:59.1560000 [client] INFO Executing 'ghcup --no-verbose list -t cabal -c installed -r' in cwd '<project root>'
2022-07-31 14:35:59.2580000 [client] INFO Checking for ghcup installation
2022-07-31 14:35:59.2680000 [client] INFO found ghcup at ghcup
2022-07-31 14:35:59.2690000 [client] INFO Executing 'ghcup --no-verbose list -t stack -c installed -r' in cwd '<project root>'
2022-07-31 14:35:59.4190000 [client] INFO Checking for ghcup installation
2022-07-31 14:35:59.4310000 [client] INFO found ghcup at ghcup
2022-07-31 14:35:59.4320000 [client] INFO Executing 'ghcup --no-verbose whereis hls 1.7.0.0' in cwd '<project root>'
2022-07-31 14:35:59.4530000 [client] INFO Checking for ghcup installation
2022-07-31 14:35:59.4640000 [client] INFO found ghcup at ghcup
2022-07-31 14:35:59.4660000 [client] INFO Executing 'ghcup --no-verbose whereis cabal 3.6.2.0' in cwd '<project root>'
2022-07-31 14:35:59.4870000 [client] INFO Checking for ghcup installation
2022-07-31 14:35:59.4970000 [client] INFO found ghcup at ghcup
2022-07-31 14:35:59.4980000 [client] INFO Executing 'ghcup --no-verbose whereis stack 2.7.5' in cwd '<project root>'
2022-07-31 14:35:59.5300000 [client] INFO Checking for ghcup installation
2022-07-31 14:35:59.5400000 [client] INFO found ghcup at ghcup
2022-07-31 14:35:59.5420000 [client] INFO Executing 'ghcup --no-verbose run --hls 1.7.0.0 --cabal 3.6.2.0 --stack 2.7.5 --install' in cwd '<project root>'
2022-07-31 14:35:59.7140000 [client] INFO Working out the project GHC version. This might take a while...
2022-07-31 14:35:59.7160000 [client] INFO Executing 'haskell-language-server-wrapper --project-ghc-version' in cwd '<project root>'

@AZMCode
Copy link

AZMCode commented Jul 31, 2022

If I can provide any further data or perform any further debugging steps I'd be glad to.

@AZMCode
Copy link

AZMCode commented Jul 31, 2022

Running extension version v2.2.0

@AZMCode
Copy link

AZMCode commented Jul 31, 2022

Can confirm all installed GHCup tools work as expected in the command line too, so no PATH issue there.

Running the last frozen command manually in the same environment yields the following logs before freezing:

No 'hie.yaml' found. Try to discover the project type!

@fendor
Copy link
Collaborator

fendor commented Jul 31, 2022

This command might install a full ghc version, can you try to run HLS on the path for your project and report the output?

E.g.

$ haskell-languag-server-wrapper --debug <path-to-your-sources>

Note, it might take a while, if you have a stack project, it will install the necessary stack project.

@AZMCode
Copy link

AZMCode commented Aug 8, 2022

This will sound kind of unbelievable, but I can't replicate this again, since I switched distros since then. I apologize for the inconvenience 😅

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

Successfully merging a pull request may close this issue.

5 participants