ionide / ionide-vscode-fsharp

VS Code plugin for F# development
http://ionide.io
MIT License
859 stars 277 forks source link

F# Language Server crashed 5 times in the last 3 minutes #1477

Closed aolney closed 3 years ago

aolney commented 3 years ago

Describe the bug**

F# Language Server crashed 5 times in the last 3 minutes

Steps to reproduce

On startup

Link to sample reproduction

https://github.com/fable-compiler/fable2-samples/tree/master/minimal

Expected behaviour

Not crashing

Machine info

Found this issue: https://github.com/fsprojects/fsharp-language-server/issues/43

Resolved by installing Ionide 4.17 from VSIX

open-collective-bot[bot] commented 3 years ago

Hey @aolney :wave:,

Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our OpenCollective and consider backing us.

https://opencollective.com/ionide

PS.: We offer backer support for all backers. Don't forget to add backer label when you start backing us :smile:

baronfel commented 3 years ago

As noted in the Release Notes for Ionide 5.0 and up, .Net 5 is required. Otherwise yes, you'll see this. Closing as designed.

baronfel commented 3 years ago

Also, please note that fsprojects/fsharp-language-server is a completely separate LSP implementation from Ionide, and it's very unlikely that issues raised in that repo have a direct correlation or relevance to this project as a result.

ladaltamirano commented 2 years ago

As noted in the Release Notes for Ionide 5.0 and up, .Net 5 is required. Otherwise yes, you'll see this. Closing as designed.

You should not close this, since your argument is invalid. I have enabled .net core 5.0.100 with a global.json file, the version 5 is active and still see the same error.

daz10000 commented 2 years ago

Just a comment since I ran into this just now. The ionide error reporting for wrong dotnet sdk versions seems to be a little fragile and misleading. I have a global.json file with an older version of the sdk mentioned (6.0.101) and had a newer version installed (6.0.202). It worked fine when I fixed the global.json file, but the traces in the F# logs are a bit confusing. The first line is right - there isn't a compatible version installed (compatible with global.json). The rest of the messages are a little chaotic. The application --version does not exist ?? Unable to parse sdk version from the string ' 6.0.202 [C:\Program Files\dotnet\sdk]' - might be hard to do, but the information is there to give the user a simple message - project asks for 6.0.101 and it's not installed. You appear to have 6.0.202 installed. This is with the F# console opened. Without that, you just hear that the F# server crashed 5 times in the last 3 minutes - which isn't a wonderful experience for a novice.

Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
  * You intended to execute a .NET program:
      The application '--version' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible installed .NET SDK for global.json version [6.0.101] from [c:\extproj\Plough.WebApi\global.json] was not found.
      Install the [6.0.101] .NET SDK or update [c:\extproj\Plough.WebApi\global.json] with an installed .NET SDK:
Unhandled exception: System.Exception: Unable to parse sdk version from the string '        6.0.202 [C:\Program Files\dotnet\sdk]'. This value came from running `C:\Program Files\dotnet\dotnet.exe [--version]` at path c:\extproj\Plough.WebApi\src\Plough.WebApi.Client.Dotnet
baronfel commented 2 years ago

Ah gotcha - since we're invoking 'dotnet --version' to check versions, if that dotnet can't be invoked by the SDK itself we need to be able to handle that. Makes sense to me.

daz10000 commented 2 years ago

Exactly,

With wrong global.json (set tp 6.0.101 vs installed 6..0.202)

$ dotnet --version
Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
  * You intended to execute a .NET program:
      The application '--version' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible installed .NET SDK for global.json version [6.0.101] from [C:\xxx\xxx\WebApi\global.json] was not found.
      Install the [6.0.101] .NET SDK or update [C:xxx\xxx\global.json] with an installed .NET SDK:
        6.0.202 [C:\Program Files\dotnet\sdk]

Once global.json is edited to match installed version of sdk

$ dotnet --version
6.0.202

So you'd have to parse that helpful but messy error message to give the GUI user a clue about what's happening.

ladaltamirano commented 2 years ago

Just a comment since I ran into this just now. The ionide error reporting for wrong dotnet sdk versions seems to be a little fragile and misleading. I have a global.json file with an older version of the sdk mentioned (6.0.101) and had a newer version installed (6.0.202). It worked fine when I fixed the global.json file, but the traces in the F# logs are a bit confusing. The first line is right - there isn't a compatible version installed (compatible with global.json). The rest of the messages are a little chaotic. The application --version does not exist ?? Unable to parse sdk version from the string ' 6.0.202 [C:\Program Files\dotnet\sdk]' - might be hard to do, but the information is there to give the user a simple message - project asks for 6.0.101 and it's not installed. You appear to have 6.0.202 installed. This is with the F# console opened. Without that, you just hear that the F# server crashed 5 times in the last 3 minutes - which isn't a wonderful experience for a novice.

Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
  * You intended to execute a .NET program:
      The application '--version' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible installed .NET SDK for global.json version [6.0.101] from [c:\extproj\Plough.WebApi\global.json] was not found.
      Install the [6.0.101] .NET SDK or update [c:\extproj\Plough.WebApi\global.json] with an installed .NET SDK:
Unhandled exception: System.Exception: Unable to parse sdk version from the string '        6.0.202 [C:\Program Files\dotnet\sdk]'. This value came from running `C:\Program Files\dotnet\dotnet.exe [--version]` at path c:\extproj\Plough.WebApi\src\Plough.WebApi.Client.Dotnet

I don't think this is my case. I have installed and active the version set up in the global.json.

What I get from the F# output is a reference to a folder path that ionide seems to send, and it breaks it: (I've already set FSharp.dotnetRoot)

Unhandled exception: System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'c:\repos\fs\FirstIonideProject\dotnet' with working directory 'c:\repos\fs\FirstIonideProject'. The system cannot find the file specified.

That dotnet folder is not created by default when scaffolding a F# project. To me ionide seems to be failing to look for the dotnet.exe ?

Give me some clues please on where should I look to correct this. I've checked my system path env var, and the first thing there is the path to dotnet sdk.

daz10000 commented 2 years ago

If you go to that folder in your favorite shell (cmd, bash etc) and type dotnet --version which does it say? If you have bash installed, try which dotnet. It seems to be looking for the dotnet binary in your project folder itself rather than the system location. If you type path in cmd shell or echo $path in bash, is c:\Program\ Files\dotnet on your path?

toburger commented 2 years ago

I get the following error:

Unhandled exception: System.ComponentModel.Win32Exception (5): An error occurred trying to start process 'C:\Program Files\dotnet' with working directory 'C:\Users\Tobias\AppData\Local\Programs\Microsoft VS Code'. Access is denied.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Ionide.ProjInfo.SdkDiscovery.execDotnet(DirectoryInfo cwd, FileInfo binaryFullPath, IEnumerable`1 args) in /_//src/Ionide.ProjInfo/Library.fs:line 34
   at Ionide.ProjInfo.SdkDiscovery.versionAt(DirectoryInfo cwd, FileInfo dotnetBinaryPath) in /_//src/Ionide.ProjInfo/Library.fs:line 105
   at Ionide.ProjInfo.Init.init(DirectoryInfo workingDirectory, FSharpOption`1 dotnetExe) in /_//src/Ionide.ProjInfo/Library.fs:line 244
   at FsAutoComplete.Parser.rootCommand@113-1.Invoke(Boolean backgroundServiceEnabled, Boolean projectGraphEnabled, DirectoryInfo stateDirectory) in /home/runner/work/FsAutoComplete/FsAutoComplete/src/FsAutoComplete/Parser.fs:line 120
   at System.CommandLine.Handler.<>c__DisplayClass21_0`3.<SetHandler>b__0(InvocationContext context)
   at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass18_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at FsAutoComplete.Parser.serilogFlush@254-1.MoveNext() in /home/runner/work/FsAutoComplete/FsAutoComplete/src/FsAutoComplete/Parser.fs:line 0
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass13_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass20_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__19_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__6_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass9_0.<<UseExceptionHandler>b__0>d.MoveNext()
[Info  - 15:22:50] Connection to server got closed. Server will restart.

Telling me it can't access 'C:\Users\Tobias\AppData\Local\Programs\Microsoft VS Code'.

I can access the path with the file explorer tough and even after starting VS Code with administrative rights I get the error. Changing the folder rights to full access to everyone doesn't help neither.

toburger commented 2 years ago

Seems my problem was caused by a wrong environment variable:

Wrong: image

Correct: image