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

Emacs 28 LSP Error On Autocomplete #876

Closed
kstatz12 opened this issue Dec 31, 2021 · 19 comments
Closed

Emacs 28 LSP Error On Autocomplete #876

kstatz12 opened this issue Dec 31, 2021 · 19 comments

Comments

@kstatz12
Copy link

when i start the lsp and start editing code instead of autocomplete i get these errors

LSP :: Guessed project root is ~/src/csharp-language-server
LSP :: Connected to [fsac:2336053/starting].
LSP :: fsac:2336053 initialized successfully in folders: (/home/karl.statz/src/csharp-language-server)
LSP :: Workspace Loaded!
Quit
fsharp--compute-indentation-relative-to-previous: End position is smaller than start position [2 times]
LSP :: Error from the Language Server: Position is out of range (Internal Error) [4 times]
Company: An error occurred in auto-begin
Company: backend (:separate company-capf company-yasnippet) error "No Typecheck results" with args (candidates Ms)
Company: An error occurred in auto-begin
Company: backend (:separate company-capf company-yasnippet) error "No Typecheck results" with args (candidates MSB)
Company: An error occurred in auto-begin
Company: backend (:separate company-capf company-yasnippet) error "No Typecheck results" with args (candidates MSBu)

Emacs 28 with doom

@kstatz12 kstatz12 closed this as completed Jan 6, 2022
@kstatz12 kstatz12 reopened this Jan 8, 2022
@fehmud
Copy link

fehmud commented Mar 15, 2022

@kstatz12, what OS are you using? Because I am experiencing the same issue with Emacs 27, but only on GNU/Linux, whilst completion works on Windows.

EDIT: Completion used to work on both OSes before updating to .NET 6.

@fehmud
Copy link

fehmud commented Mar 15, 2022

P.S.: Completion on GNU/Linux does not work with Ionide in Visual Studio Code either.

@vzarytovskii
Copy link

@fehmud do you happen to have any logs from LSP (should be a separate buffer).
Does anything else work? Type hints, for example?
Also, what locale do you use? It sounds awfully similar to #871

@fehmud
Copy link

fehmud commented Mar 21, 2022

@vzarytovskii Yes! There is *fsac::stderr*, with lots of debugging messages. By looking at it, it seems that FSAC can't find standard .NET assemblies:

[19:33:48.016 DBG] [FileSystem] Is System.Numerics.dll rooted? False
[19:33:48.016 DBG] [FileSystem] Is System.dll rooted? False

and then there is the message "Assembly reference 'mscorlib.dll' was not found or is invalid".

Yet, my .NET 6 Runtime is in its standard location. Here is the output of locate mscorlib.dll:

/usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/6.0.2/ref/net6.0/mscorlib.dll
/usr/share/dotnet/packs/NETStandard.Library.Ref/2.1.0/ref/netstandard2.1/mscorlib.dll
/usr/share/dotnet/sdk/6.0.200/ref/mscorlib.dll
/usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.2/mscorlib.dll

I have also set the environment variable export DOTNET_ROLL_FORWARD to LatestMajor, to make sure that the latest runtime is loaded.

Deleting the ./obj, ./bin and ./.ionide folders and reopening the project after restarting Emacs doesn't fix the issue.

@fehmud
Copy link

fehmud commented Mar 23, 2022

Here are the two lines of the log that repeat whenever I try to complete, with JSON pretty-printed for clarity:

[00:16:42.894 INF] [Checker] ParseAndCheckFileInProject - "/home/fehmud/projects/fsharp/sorting/source/Program.fs" completed with errors:
    [
        {
            "Range": {
                "End": {
                    "Column": 0,
                    "Line": 1,
                    "$type": "<>f__AnonymousType2572016585`2"
                },
                "FileName": "unknown",
                "Start": {
                    "Column": 0,
                    "Line": 1,
                    "$type": "<>f__AnonymousType2572016585`2"
                },
                "$type": "<>f__AnonymousType2238999571`3"
            },
            "Severity": {
                "$type": "Error"
            },
            "Message": "Assembly reference 'mscorlib.dll' was not found or is invalid",
            "Subcategory": "parameter",
            "ErrorNumber": 84,
            "ErrorNumberPrefix": "FS",
            "ErrorNumberText": "FS0084",
            "Start": {
                "Column": 0,
                "Line": 1,
                "$type": "<>f__AnonymousType2572016585`2"
            },
            "End": {
                "Column": 0,
                "Line": 1,
                "$type": "<>f__AnonymousType2572016585`2"
            },
            "StartLine": 1,
            "EndLine": 1,
            "StartColumn": 0,
            "EndColumn": 0,
            "FileName": "unknown",
            "$type": "FSharpDiagnostic"
        },
        {
            "Range": {
                "End": {
                    "Column": 0,
                    "Line": 0,
                    "$type": "<>f__AnonymousType2572016585`2"
                },
                "FileName": "unknown",
                "Start": {
                    "Column": 0,
                    "Line": 0,
                    "$type": "<>f__AnonymousType2572016585`2"
                },
                "$type": "<>f__AnonymousType2238999571`3"
            },
            "Severity": {
                "$type": "Error"
            },
            "Message": "internal error: One or more errors occurred. (The exception has been reported. This internal exception should now be caught at an error recovery point on the stack. Original message: Exception of type 'FSharp.Compiler.CompilerImports+AssemblyNotResolved' was thrown.))",
            "Subcategory": "parameter",
            "ErrorNumber": 193,
            "ErrorNumberPrefix": "FS",
            "ErrorNumberText": "FS0193",
            "Start": {
                "Column": 0,
                "Line": 0,
                "$type": "<>f__AnonymousType2572016585`2"
            },
            "End": {
                "Column": 0,
                "Line": 0,
                "$type": "<>f__AnonymousType2572016585`2"
            },
            "StartLine": 0,
            "EndLine": 0,
            "StartColumn": 0,
            "EndColumn": 0,
            "FileName": "unknown",
            "$type": "FSharpDiagnostic"
        }
    ]

[00:16:42.910 VRB] [LSP] Errors while processing code action request
    for file:///home/fehmud/projects/fsharp/sorting/source/Program.fs
    with {"Diagnostics": [], "$type": "CodeActionContext"}
    at {"Start": {"Line": 3, "Character": 0, "$type": "Position"}, "End": {"Line": 3, "Character": 0, "$type": "Position"}, "$type": "Range"}
    [
        "No typecheck results available for \"/home/fehmud/projects/fsharp/sorting/source/Program.fs\"",
        "No typecheck results available for \"/home/fehmud/projects/fsharp/sorting/source/Program.fs\"",
        "No typecheck results available for \"/home/fehmud/projects/fsharp/sorting/source/Program.fs\"",
        "No typecheck results available for \"/home/fehmud/projects/fsharp/sorting/source/Program.fs\"",
        "No typecheck results available for \"/home/fehmud/projects/fsharp/sorting/source/Program.fs\"",
        "No typecheck results available for \"/home/fehmud/projects/fsharp/sorting/source/Program.fs\""
    ]

@vzarytovskii
Copy link

Yep, can reproduce it on WSL2:

[15:25:48.155 INF] [Checker] ParseAndCheckFileInProject - "/home/u/code/fsharp/src/fsharp/AccessibilityLogic.fs" completed with errors: 
[
   {
      "Range":{
         "End":{
            "Column":0,
            "Line":1,
            "$type":"<>f__AnonymousType2572016585`2"
         },
         "FileName":"unknown",
         "Start":{
            "Column":0,
            "Line":1,
            "$type":"<>f__AnonymousType2572016585`2"
         },
         "$type":"<>f__AnonymousType2238999571`3"
      },
      "Severity":{
         "$type":"Error"
      },
      "Message":"Assembly reference 'mscorlib.dll' was not found or is invalid",
      "Subcategory":"parameter",
      "ErrorNumber":84,
      "ErrorNumberPrefix":"FS",
      "ErrorNumberText":"FS0084",
      "Start":{
         "Column":0,
         "Line":1,
         "$type":"<>f__AnonymousType2572016585`2"
      },
      "End":{
         "Column":0,
         "Line":1,
         "$type":"<>f__AnonymousType2572016585`2"
      },
      "StartLine":1,
      "EndLine":1,
      "StartColumn":0,
      "EndColumn":0,
      "FileName":"unknown",
      "$type":"FSharpDiagnostic"
   },
   {
      "Range":{
         "End":{
            "Column":0,
            "Line":0,
            "$type":"<>f__AnonymousType2572016585`2"
         },
         "FileName":"unknown",
         "Start":{
            "Column":0,
            "Line":0,
            "$type":"<>f__AnonymousType2572016585`2"
         },
         "$type":"<>f__AnonymousType2238999571`3"
      },
      "Severity":{
         "$type":"Error"
      },
      "Message":"internal error: One or more errors occurred. (The exception has been reported. This internal exception should now be caught at an error recovery point on the stack. Original message: Exception of type 'FSharp.Compiler.CompilerImports+AssemblyNotResolved' was thrown.))",
      "Subcategory":"parameter",
      "ErrorNumber":193,
      "ErrorNumberPrefix":"FS",
      "ErrorNumberText":"FS0193",
      "Start":{
         "Column":0,
         "Line":0,
         "$type":"<>f__AnonymousType2572016585`2"
      },
      "End":{
         "Column":0,
         "Line":0,
         "$type":"<>f__AnonymousType2572016585`2"
      },
      "StartLine":0,
      "EndLine":0,
      "StartColumn":0,
      "EndColumn":0,
      "FileName":"unknown",
      "$type":"FSharpDiagnostic"
   }
]
u@DESKTOP-S2UFOG2:~/code/fsharp$ uname -a && cat /etc/issue && dotnet --info
Linux DESKTOP-S2UFOG2 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu Jammy Jellyfish (development branch) \n \l

.NET SDK (reflecting any global.json):
 Version:   6.0.201
 Commit:    ef40e6aa06

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.201/

Host (useful for support):
  Version: 6.0.3
  Commit:  c24d9a9c91

.NET SDKs installed:
  6.0.201 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]```

@razzmatazz
Copy link
Contributor

There seems to be an issue when you have 6.0 installed, as fsac itself is built w/ .net 5 -- but not sure if thats the cause.

If I install just .net 5 sdk then things start to work, tested on macos and linux.

@vzarytovskii
Copy link

There seems to be an issue when you have 6.0 installed, as fsac itself is built w/ .net 5 -- but not sure if thats the cause.

If I install just .net 5 sdk then things start to work, tested on macos and linux.

Huh, let me try installing net5 sdk

@baronfel
Copy link
Contributor

I wonder if the next FSAC release will solve this - we've bumped the required TFM to net6.0 in a recent MR.

@vzarytovskii
Copy link

There seems to be an issue when you have 6.0 installed, as fsac itself is built w/ .net 5 -- but not sure if thats the cause.

If I install just .net 5 sdk then things start to work, tested on macos and linux.

Nope, that did not help me, it still fails with the same message.

@fehmud
Copy link

fehmud commented May 13, 2022

I have just installed FSAC 0.53.1 and now completion works with .NET 6.0.200 on GNU/Linux. Thank you!

@baronfel
Copy link
Contributor

Glad to hear it!

@fehmud
Copy link

fehmud commented May 29, 2022

Regrettably I have reinstalled my PC and now completion in Emacs fails again with the same error. Completion doesn't work either with Ionide in Visual Studio Code.

My .NET version now is 6.0.300. That is the only difference that I am aware of.

@fehmud
Copy link

fehmud commented Jun 5, 2022

Now I have FSAC working with Ionide v6.0.5 in Visual Studio Code.

Still no luck in Emacs. The *fsac::stderr* buffer only contains:

Process fsac stderr finished

even though I have configured LSP to launch it with --verbose.

@razzmatazz
Copy link
Contributor

@fehmud what is your exec-path on emacs? does it point to ~/.dotnet + ~/.dotnet/tools ?

@fehmud
Copy link

fehmud commented Jun 6, 2022

@razzmatazz There is ~/.dotnet/tools/ but no ~/.dotnet, but then there is no executable in either directory anyway. As for FSAC, I have set lsp-fsharp-server-install-dir to run fsautocomplete.dll from Ionide's installation, which runs fine both in Visual Studio Code and from the command line. I tried the fsautocomplete tool but with no success.

Thanks everybody for the assistance, but no more F# in Emacs for me.

@razzmatazz
Copy link
Contributor

razzmatazz commented Jun 6, 2022

there should be fsautocomplete in ~/.dotnet/tools if you have the server installed via dotnet tools -- this is on my fedora/linux machine:

bob@saulius-desktop ~ » ls -l ~/.dotnet/tools                                                                                                                                                                   2 ↵
insgesamt 700
-rwxr-xr-x. 1 bob bob 142840 13. Dez 08:36 dotnet-dump
-rwxr-xr-x. 1 bob bob 142840  9. Feb 14:55 dotnet-pstacks
-rwxr-xr-x. 1 bob bob 142840 25. Nov 2021  dotnet-stack
-rwxr-xr-x. 1 bob bob 142840 25. Jan 14:10 dotnet-trace
-rwxr-xr-x. 1 bob bob 142840 10. Mai 22:05 fsautocomplete

@fehmud
Copy link

fehmud commented Jun 6, 2022

@razzmatazz
I have tried again after installing fsautocomplete as a tool, and downloading the bleeding-edge LSP Mode. FSAC now works, for I get suggestions for refactorings, but still no completion for basic modules like System. I get this message instead:

LSP :: Error from the Language Server: No tooltip information (Internal Error)

Normally, I would try to debug a package, but LSP Mode seems too complex.

@TheAngryByrd
Copy link
Member

I think this was related to issues with finding references that #1038 fixed. Let me know if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants