lsp-mode icon indicating copy to clipboard operation
lsp-mode copied to clipboard

C# language server doesn't work at all

Open EmilyGraceSeville7cf opened this issue 2 years ago • 5 comments

Thank you for the bug report

  • [X] I am using the latest version of lsp-mode related packages.
  • [X] I checked FAQ and Troubleshooting sections
  • [ ] You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

No completion shown for an opened C# program.

Steps to reproduce

  • dotnet new console --name Test
  • dotnet new sln --name Test
  • dotnet sln add ./Test/Test.csproj
  • emacs -nw ./Test/Program.cs
  • change file contents to:
    using System;
    
    class Program
    {
        private static void Main()
        {
        Console.
        }
    }
    
  • move cursor straight after Console.
  • M-x package-install RET csharp-mode
  • M-x csharp-mode
  • M-x lsp-install-server RET omnisharp
  • M-x company-mode
  • M-x lsp
  • type Rea and obtain no completions for Read and ReadLine and other methods with this prefix

image

Expected behavior

Completion pop-up appeared for Rea word.

Which Language Server did you use?

C# (Omnisharp-Roslyn)

OS

Linux

Error callstack

‘soft-stone-theme’ is already installed
‘flycheck’ is already installed
‘markdown-mode’ is already installed
‘json-mode’ is already installed
‘yaml-mode’ is already installed
‘format-all’ is already installed
‘lsp-mode’ is already installed
‘lsp-pyright’ is already installed
‘company’ is already installed
Saving file /home/emilyseville7cfg/.emacs...
Wrote /home/emilyseville7cfg/.emacs
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list...
Saving file /home/emilyseville7cfg/.emacs...
Wrote /home/emilyseville7cfg/.emacs
Contacting host: melpa.org:443 [2 times]
Parsing tar file...done
Extracting...done
  INFO     Scraping files for csharp-mode-autoloads.el... 
Generating autoloads for csharp-compilation.el...done
Generating autoloads for csharp-mode-pkg.el...done
Generating autoloads for csharp-mode.el...done
Generating autoloads for csharp-tree-sitter.el...done
  INFO     Scraping files for csharp-mode-autoloads.el...done
Wrote /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242/csharp-mode-autoloads.el [2 times]
Checking /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242...
Compiling /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242/csharp-compilation.el...done
Wrote /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242/csharp-compilation.elc
Checking /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242... [3 times]
Compiling /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242/csharp-mode.el...done
Wrote /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242/csharp-mode.elc
Checking /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242...
Compiling /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242/csharp-tree-sitter.el...done
Wrote /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242/csharp-tree-sitter.elc
Checking /home/emilyseville7cfg/.emacs.d/elpa/csharp-mode-20220704.1242...
Done (Total of 3 files compiled, 2 skipped)
Package ‘csharp-mode’ installed.
You can run the command ‘csharp-mode’ with M-x csh-m RET
Saving file /home/emilyseville7cfg/Documents/Mine/CSharp/Test/Program.cs...
Wrote /home/emilyseville7cfg/Documents/Mine/CSharp/Test/Program.cs
Quit
The first line should be of the form: ";;; package --- Summary"
You should have a section marked ";;; Commentary:"
Saving file /home/emilyseville7cfg/Documents/Mine/CSharp/Test/Program.cs...
Wrote /home/emilyseville7cfg/Documents/Mine/CSharp/Test/Program.cs
LSP :: Download omnisharp started.
LSP :: Starting to download https://github.com/omnisharp/omnisharp-roslyn/releases/latest/download/omnisharp-linux-x64.zip to /home/emilyseville7cfg/.emacs.d/.cache/lsp/omnisharp-roslyn/latest/omnisharp-roslyn.zip...
Contacting host: github.com:443
Wrote /home/emilyseville7cfg/.emacs.d/.cache/lsp/omnisharp-roslyn/latest/omnisharp-roslyn.zip
LSP :: Finished downloading /home/emilyseville7cfg/.emacs.d/.cache/lsp/omnisharp-roslyn/latest/omnisharp-roslyn.zip...
(Shell command succeeded with no output)
LSP :: Server omnisharp downloaded, auto-starting in 0 buffers.
Making completion list...
Company mode enabled in current buffer
LSP :: Yasnippet is not installed, but `lsp-enable-snippet' is set to `t'. You must either install yasnippet, or disable snippet support.
LSP :: Connected to [omnisharp:17919/starting].
Auto-saving...done

Anything else?

My ~/.emacs config:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

(setq packages '(soft-stone-theme flycheck markdown-mode json-mode yaml-mode format-all lsp-mode lsp-pyright company))

(dolist (package packages)
  (package-install package))

(add-hook 'after-init-hook (lambda () (load-theme 'soft-stone t)))
(add-hook 'after-init-hook #'global-flycheck-mode)

(setq omnisharp-expected-server-version "1.32.0") ; https://github.com/OmniSharp/omnisharp-vscode/issues/1450#issuecomment-432516876
(let ((dotnet-version (string-trim (shell-command-to-string "dotnet --version"))))
  ;; https://github.com/OmniSharp/omnisharp-emacs/issues/459#issuecomment-452656947
  (setenv "MSBuildSDKsPath" (format "/usr/share/dotnet/sdk/%s/Sdks" dotnet-version)))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(display-line-numbers 'relative)
 '(package-selected-packages
   '(csharp-mode company lsp-pyright lsp-mode format-all yaml-mode json-mode markdown-mode flycheck soft-stone-theme)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

EmilyGraceSeville7cf avatar Aug 06 '22 08:08 EmilyGraceSeville7cf

cc @razzmatazz

yyoncho avatar Aug 06 '22 09:08 yyoncho

hey @EmilySeville7cfg

could you do M-x lsp-toggle-trace-io and get a dump of conversation log w/ the server?

the trace should be available on emacs *lsp-log: omnisharp:$(PID)* buffer

also, what happens when you run $(PATH-TO-INSTALLED-OMNISHARP) -lsp on the root folder of directory, does it start properly?

which linux distro are you running, which architecture?

which dotnet sdk version are you testing this with?

razzmatazz avatar Aug 07 '22 18:08 razzmatazz

also -- have you tried installing csharp-ls -- does it behave better/worse/does it not start as well?

razzmatazz avatar Aug 07 '22 18:08 razzmatazz

could you do M-x lsp-toggle-trace-io and get a dump of conversation log w/ the server?

[Trace - 07:20:41 AM] Sending request 'initialize - (1)'.
Params: {
  "processId": null,
  "rootPath": "/home/emilyseville7cfg/Documents/Mine/CSharpTest/Test",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0)\n of 2022-05-31"
  },
  "rootUri": "file:///home/emilyseville7cfg/Documents/Mine/CSharpTest/Test",
  "capabilities": {
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },
      "applyEdit": true,
      "symbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        }
      },
      "executeCommand": {
        "dynamicRegistration": false
      },
      "didChangeWatchedFiles": {
        "dynamicRegistration": true
      },
      "workspaceFolders": true,
      "configuration": true,
      "codeLens": {
        "refreshSupport": true
      },
      "fileOperations": {
        "didCreate": false,
        "willCreate": false,
        "didRename": true,
        "willRename": true,
        "didDelete": false,
        "willDelete": false
      }
    },
    "textDocument": {
      "declaration": {
        "linkSupport": true
      },
      "definition": {
        "linkSupport": true
      },
      "implementation": {
        "linkSupport": true
      },
      "typeDefinition": {
        "linkSupport": true
      },
      "synchronization": {
        "willSave": true,
        "didSave": true,
        "willSaveWaitUntil": true
      },
      "documentSymbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        },
        "hierarchicalDocumentSymbolSupport": true
      },
      "formatting": {
        "dynamicRegistration": true
      },
      "rangeFormatting": {
        "dynamicRegistration": true
      },
      "rename": {
        "dynamicRegistration": true,
        "prepareSupport": true
      },
      "codeAction": {
        "dynamicRegistration": true,
        "isPreferredSupport": true,
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "",
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        },
        "resolveSupport": {
          "properties": [
            "edit",
            "command"
          ]
        },
        "dataSupport": true
      },
      "completion": {
        "completionItem": {
          "snippetSupport": false,
          "documentationFormat": [
            "markdown",
            "plaintext"
          ],
          "resolveAdditionalTextEditsSupport": true,
          "insertReplaceSupport": true,
          "deprecatedSupport": true,
          "resolveSupport": {
            "properties": [
              "documentation",
              "detail",
              "additionalTextEdits",
              "command"
            ]
          },
          "insertTextModeSupport": {
            "valueSet": [
              1,
              2
            ]
          }
        },
        "contextSupport": true
      },
      "signatureHelp": {
        "signatureInformation": {
          "parameterInformation": {
            "labelOffsetSupport": true
          }
        }
      },
      "documentLink": {
        "dynamicRegistration": true,
        "tooltipSupport": true
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ]
      },
      "foldingRange": {
        "dynamicRegistration": true
      },
      "callHierarchy": {
        "dynamicRegistration": false
      },
      "publishDiagnostics": {
        "relatedInformation": true,
        "tagSupport": {
          "valueSet": [
            1,
            2
          ]
        },
        "versionSupport": true
      },
      "linkedEditingRange": {
        "dynamicRegistration": true
      }
    },
    "window": {
      "workDoneProgress": true,
      "showDocument": {
        "support": true
      }
    }
  },
  "initializationOptions": null,
  "workDoneToken": "1"
}


[Trace - 07:20:42 AM] Received notification 'window/logMessage'.
Params: {
  "type": 3,
  "message": "OmniSharp.Services.DotNetCliService: Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK | "
}


[Trace - 07:20:42 AM] Received notification 'window/logMessage'.
Params: {
  "type": 3,
  "message": "OmniSharp.Services.DotNetCliService: Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK | "
}


[Trace - 07:20:42 AM] Received notification 'window/logMessage'.
Params: {
  "type": 3,
  "message": "OmniSharp.Services.DotNetCliService: Using the 'dotnet' on the PATH. | "
}


[Trace - 07:20:42 AM] Received notification 'window/logMessage'.
Params: {
  "type": 3,
  "message": "OmniSharp.Services.DotNetCliService: Using the 'dotnet' on the PATH. | "
}


[Trace - 07:20:42 AM] Received notification 'window/logMessage'.
Params: {
  "type": 3,
  "message": "OmniSharp.Services.DotNetCliService: DotNetPath set to dotnet | "
}


[Trace - 07:20:42 AM] Received notification 'window/logMessage'.
Params: {
  "type": 3,
  "message": "OmniSharp.Services.DotNetCliService: DotNetPath set to dotnet | "
}


[Trace - 07:20:43 AM] Received notification 'window/logMessage'.
Params: {
  "type": 3,
  "message": "OmniSharp.MSBuild.Discovery.MSBuildLocator: Located 0 MSBuild instance(s) | "
}


[Trace - 07:20:43 AM] Received notification 'window/logMessage'.
Params: {
  "type": 3,
  "message": "OmniSharp.MSBuild.Discovery.MSBuildLocator: Located 0 MSBuild instance(s) | "
}


[Trace - 07:20:43 AM] Received notification 'window/logMessage'.
Params: {
  "type": 1,
  "message": "OmniSharp.Extensions.JsonRpc.InputHandler: Failed to handle request initialize 1 - OmniSharp.MSBuild.Discovery.MSBuildNotFoundException: Could not locate MSBuild instance to register with OmniSharp.\n  at OmniSharp.MSBuild.Discovery.Extensions.RegisterDefaultInstance (OmniSharp.MSBuild.Discovery.IMSBuildLocator msbuildLocator, Microsoft.Extensions.Logging.ILogger logger, OmniSharp.Services.DotNetInfo dotNetInfo) [0x000b1] in <57c3ddd2af334170914622a16d8ae165>:0 \n  at OmniSharp.CompositionHostBuilder.Build (System.String workingDirectory) [0x000ad] in <57c3ddd2af334170914622a16d8ae165>:0 \n  at OmniSharp.LanguageServerProtocol.LanguageServerHost.CreateCompositionHost (OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer server, OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams initializeParams, OmniSharp.CommandLineApplication application, Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action`1[T] configureLogging) [0x0017d] in <75f71f74cf794ac1b25b9aaef7ed476d>:0 \n  at OmniSharp.LanguageServerProtocol.LanguageServerHost.Initialize (OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer server, OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams initializeParams, System.Threading.CancellationToken cancellationToken) [0x00000] in <75f71f74cf794ac1b25b9aaef7ed476d>:0 \n  at OmniSharp.Extensions.LanguageServer.Server.LanguageServer+<>c__DisplayClass77_0.<MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InternalInitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle>b__0 (OmniSharp.Extensions.LanguageServer.Protocol.Server.OnLanguageServerInitializeDelegate handler, System.Threading.CancellationToken ct) [0x00012] in <a65ee41ef84f44d8810b866724a97eec>:0 \n  at OmniSharp.Extensions.LanguageServer.Protocol.LanguageProtocolEventingHelper+<>c__DisplayClass0_1`2[TDelegate,THandler].<Run>b__2 (System.Threading.CancellationToken ct) [0x00000] in <16970f5ac0364766b872ef4b5abe0a02>:0 \n  at System.Reactive.Linq.QueryLanguage.StartAsyncImpl (System.Func`2[T,TResult] actionAsync, System.Reactive.Concurrency.IScheduler scheduler) [0x0000d] in <3a11ea46836344a282870ba916885e3d>:0 \n--- End of stack trace from previous location where exception was thrown ---\n\n  at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InternalInitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle (OmniSharp.Extensions.LanguageServer.Protocol.Models.InternalInitializeParams request, System.Threading.CancellationToken token) [0x00133] in <a65ee41ef84f44d8810b866724a97eec>:0 \n  at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x0031e] in <a65ee41ef84f44d8810b866724a97eec>:0 \n  at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x00077] in <a65ee41ef84f44d8810b866724a97eec>:0 \n  at MediatR.Pipeline.RequestPreProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x0013e] in <856ae299ee314304bc3affd17d8d5868>:0 \n  at MediatR.Pipeline.RequestPostProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x0007e] in <856ae299ee314304bc3affd17d8d5868>:0 \n  at MediatR.Pipeline.RequestExceptionProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x00084] in <856ae299ee314304bc3affd17d8d5868>:0 \n  at MediatR.Pipeline.RequestExceptionProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x00276] in <856ae299ee314304bc3affd17d8d5868>:0 \n  at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x00084] in <856ae299ee314304bc3affd17d8d5868>:0 \n  at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x001e7] in <856ae299ee314304bc3affd17d8d5868>:0 \n  at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1[TDescriptor].<RouteRequest>g__InnerRoute|5_0 (Microsoft.Extensions.DependencyInjection.IServiceScopeFactory serviceScopeFactory, OmniSharp.Extensions.JsonRpc.Server.Request request, TDescriptor descriptor, System.Object params, System.Threading.CancellationToken token, Microsoft.Extensions.Logging.ILogger logger) [0x000fc] in <f52078c2a67749cdb3fc490a4675d4eb>:0 \n  at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1[TDescriptor].RouteRequest (OmniSharp.Extensions.JsonRpc.IRequestDescriptor`1[TDescriptor] descriptors, OmniSharp.Extensions.JsonRpc.Server.Request request, System.Threading.CancellationToken token) [0x00622] in <f52078c2a67749cdb3fc490a4675d4eb>:0 \n  at OmniSharp.Extensions.JsonRpc.InputHandler+<>c__DisplayClass38_0.<RouteRequest>b__5 (System.Threading.CancellationToken ct) [0x000f2] in <f52078c2a67749cdb3fc490a4675d4eb>:0  | Method='initialize' RequestId='1'"
}


[Trace - 07:20:43 AM] Received notification 'window/logMessage'.
Params: {
  "type": 2,
  "message": "OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError | @Request='OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError'"
}

which linux distro are you running, which architecture?


           `:+shmNNMMNNmhs+:`              emilyseville7cfg@EmilySeville7cfgPC 
        .odMMMMMMMMMMMMMMMMMMdo.           ----------------------------------- 
      /dMMMMMMMMMMMMMMMmMMMMMMMMd/         OS: Ubuntu MATE 22.04.1 LTS x86_64 
    :mMMMMMMMMMMMMNNNNM/`/yNMMMMMMm:       Host: VPCEB4Z1R C608UGVE 
  `yMMMMMMMMMms:..-::oM:    -omMMMMMy`     Kernel: 5.15.0-43-generic 
 `dMMMMMMMMy-.odNMMMMMM:    -odMMMMMMd`    Uptime: 1 hour, 8 mins 
 hMMMMMMMm-.hMMy/....+M:`/yNm+mMMMMMMMh    Packages: 2292 (dpkg), 16 (snap) 
/MMMMNmMN-:NMy`-yNMMMMMmNyyMN:`dMMMMMMM/   Shell: zsh 5.8.1 
hMMMMm -odMMh`sMMMMMMMMMMs sMN..MMMMMMMh   Resolution: 1920x1080 
NMMMMm    `/yNMMMMMMMMMMMM: MM+ mMMMMMMN   DE: MATE 1.26.0 
NMMMMm    `/yNMMMMMMMMMMMM: MM+ mMMMMMMN   WM: Metacity (Marco) 
hMMMMm -odMMh sMMMMMMMMMMs oMN..MMMMMMMh   Theme: Yaru-red [GTK2/3] 
/MMMMNNMN-:NMy`-yNMMMMMNNsyMN:`dMMMMMMM/   Icons: Yaru [GTK2/3] 
 hMMMMMMMm-.hMMy/....+M:.+hNd+mMMMMMMMh    Terminal: kitty 
 `dMMMMMMMMy-.odNMMMMMM:    :smMMMMMMd`    CPU: Intel i5 M 480 (4) @ 2.667GHz 
   yMMMMMMMMMms/..-::oM:    .+dMMMMMy      GPU: AMD ATI Mobility Radeon HD 5650/5750 / 6530M/6550M 
    :mMMMMMMMMMMMMNNNNM: :smMMMMMMm:       Memory: 2085MiB / 3780MiB 
      /dMMMMMMMMMMMMMMMdNMMMMMMMd/
        .odMMMMMMMMMMMMMMMMMMdo.                                   
           `:+shmNNMMNNmhs+:`                                      

which dotnet sdk version are you testing this wit

6.0.302, I've installed it via these instructions.

EmilyGraceSeville7cf avatar Aug 07 '22 21:08 EmilyGraceSeville7cf

Please delete my comment above, I can't do it here.

Why this LSP server requires mono to be installed? Without it server fails with:

/home/emilyseville7cfg/.emacs.d/.cache/lsp/omnisharp-roslyn/latest/omnisharp-roslyn/run: line 19: mono: command not found

could you do M-x lsp-toggle-trace-io and get a dump of conversation log w/ the server?

It's interesting but this command doesn't work until I call C-h f lsp-toggle-trace-io for it (nothing else is done before this command). 🤔

image

Found the following clients for /home/emilyseville7cfg/Documents/Mine/CSharpTest/Test/Program.cs: (server-id omnisharp, priority -1)
The following clients were selected based on priority: (server-id omnisharp, priority -1)
OmniSharp.Services.DotNetCliService: Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK | 
OmniSharp.Services.DotNetCliService: Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK | 
OmniSharp.Services.DotNetCliService: Using the 'dotnet' on the PATH. | 
OmniSharp.Services.DotNetCliService: Using the 'dotnet' on the PATH. | 
OmniSharp.Services.DotNetCliService: DotNetPath set to dotnet | 
OmniSharp.Services.DotNetCliService: DotNetPath set to dotnet | 
OmniSharp.MSBuild.Discovery.MSBuildLocator: Located 0 MSBuild instance(s) | 
OmniSharp.MSBuild.Discovery.MSBuildLocator: Located 0 MSBuild instance(s) | 
OmniSharp.Extensions.JsonRpc.InputHandler: Failed to handle request initialize 1 - OmniSharp.MSBuild.Discovery.MSBuildNotFoundException: Could not locate MSBuild instance to register with OmniSharp.
  at OmniSharp.MSBuild.Discovery.Extensions.RegisterDefaultInstance (OmniSharp.MSBuild.Discovery.IMSBuildLocator msbuildLocator, Microsoft.Extensions.Logging.ILogger logger, OmniSharp.Services.DotNetInfo dotNetInfo) [0x000b1] in <57c3ddd2af334170914622a16d8ae165>:0 
  at OmniSharp.CompositionHostBuilder.Build (System.String workingDirectory) [0x000ad] in <57c3ddd2af334170914622a16d8ae165>:0 
  at OmniSharp.LanguageServerProtocol.LanguageServerHost.CreateCompositionHost (OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer server, OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams initializeParams, OmniSharp.CommandLineApplication application, Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action`1[T] configureLogging) [0x0017d] in <75f71f74cf794ac1b25b9aaef7ed476d>:0 
  at OmniSharp.LanguageServerProtocol.LanguageServerHost.Initialize (OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer server, OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams initializeParams, System.Threading.CancellationToken cancellationToken) [0x00000] in <75f71f74cf794ac1b25b9aaef7ed476d>:0 
  at OmniSharp.Extensions.LanguageServer.Server.LanguageServer+<>c__DisplayClass77_0.<MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InternalInitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle>b__0 (OmniSharp.Extensions.LanguageServer.Protocol.Server.OnLanguageServerInitializeDelegate handler, System.Threading.CancellationToken ct) [0x00012] in <a65ee41ef84f44d8810b866724a97eec>:0 
  at OmniSharp.Extensions.LanguageServer.Protocol.LanguageProtocolEventingHelper+<>c__DisplayClass0_1`2[TDelegate,THandler].<Run>b__2 (System.Threading.CancellationToken ct) [0x00000] in <16970f5ac0364766b872ef4b5abe0a02>:0 
  at System.Reactive.Linq.QueryLanguage.StartAsyncImpl (System.Func`2[T,TResult] actionAsync, System.Reactive.Concurrency.IScheduler scheduler) [0x0000d] in <3a11ea46836344a282870ba916885e3d>:0 
--- End of stack trace from previous location where exception was thrown ---

  at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InternalInitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle (OmniSharp.Extensions.LanguageServer.Protocol.Models.InternalInitializeParams request, System.Threading.CancellationToken token) [0x00133] in <a65ee41ef84f44d8810b866724a97eec>:0 
  at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x0031e] in <a65ee41ef84f44d8810b866724a97eec>:0 
  at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x00077] in <a65ee41ef84f44d8810b866724a97eec>:0 
  at MediatR.Pipeline.RequestPreProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x0013e] in <856ae299ee314304bc3affd17d8d5868>:0 
  at MediatR.Pipeline.RequestPostProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x0007e] in <856ae299ee314304bc3affd17d8d5868>:0 
  at MediatR.Pipeline.RequestExceptionProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x00084] in <856ae299ee314304bc3affd17d8d5868>:0 
  at MediatR.Pipeline.RequestExceptionProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x00276] in <856ae299ee314304bc3affd17d8d5868>:0 
  at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x00084] in <856ae299ee314304bc3affd17d8d5868>:0 
  at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, MediatR.RequestHandlerDelegate`1[TResponse] next) [0x001e7] in <856ae299ee314304bc3affd17d8d5868>:0 
  at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1[TDescriptor].<RouteRequest>g__InnerRoute|5_0 (Microsoft.Extensions.DependencyInjection.IServiceScopeFactory serviceScopeFactory, OmniSharp.Extensions.JsonRpc.Server.Request request, TDescriptor descriptor, System.Object params, System.Threading.CancellationToken token, Microsoft.Extensions.Logging.ILogger logger) [0x000fc] in <f52078c2a67749cdb3fc490a4675d4eb>:0 
  at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1[TDescriptor].RouteRequest (OmniSharp.Extensions.JsonRpc.IRequestDescriptor`1[TDescriptor] descriptors, OmniSharp.Extensions.JsonRpc.Server.Request request, System.Threading.CancellationToken token) [0x00622] in <f52078c2a67749cdb3fc490a4675d4eb>:0 
  at OmniSharp.Extensions.JsonRpc.InputHandler+<>c__DisplayClass38_0.<RouteRequest>b__5 (System.Threading.CancellationToken ct) [0x000f2] in <f52078c2a67749cdb3fc490a4675d4eb>:0  | Method='initialize' RequestId='1'
OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError | @Request='OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError'

sudo find / -iname '*msbuild*' -not -ipath '*.emacs.d*' 2> /dev/null produces following results:

/home/emilyseville7cfg/Documents/Mine/CSharpTest/Test/obj/Debug/net6.0/Test.GeneratedMSBuildEditorConfig.editorconfig
/home/emilyseville7cfg/Documents/Mine/CSharp/Backup/obj/Debug/net6.0/Backup.GeneratedMSBuildEditorConfig.editorconfig
/home/emilyseville7cfg/Documents/Mine/CSharp/Backup/obj/Debug/net6.0/Test.GeneratedMSBuildEditorConfig.editorconfig
/home/emilyseville7cfg/.vscode/extensions/ms-dotnettools.csharp-1.25.0-linux-x64/.razor/OmniSharpPlugin/OmniSharp.MSBuild.dll
/home/emilyseville7cfg/.vscode/extensions/ms-dotnettools.csharp-1.25.0-linux-x64/.omnisharp/1.39.0-net6.0/OmniSharp.MSBuild.pdb
/home/emilyseville7cfg/.vscode/extensions/ms-dotnettools.csharp-1.25.0-linux-x64/.omnisharp/1.39.0-net6.0/OmniSharp.MSBuild.dll
/usr/share/dotnet/sdk/6.0.302/pl/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/it/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/pl/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/it/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/es/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/tr/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/cs/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/zh-Hans/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/fr/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/ru/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/ja/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/ko/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/pt-BR/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/de/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/zh-Hant/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-watch/6.0.302-servicing.22323.12/tools/net6.0/any/Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/pl/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/it/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/es/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/tr/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/cs/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/zh-Hans/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/fr/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/ru/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/ja/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/ko/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/pt-BR/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/de/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/zh-Hant/Microsoft.CodeAnalysis.Workspaces.MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/DotnetTools/dotnet-format/Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
/usr/share/dotnet/sdk/6.0.302/MSBuild.dll
/usr/share/dotnet/sdk/6.0.302/minimumMSBuildVersion
/usr/share/dotnet/sdk/6.0.302/es/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/MSBuild.runtimeconfig.json
/usr/share/dotnet/sdk/6.0.302/tr/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/cs/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/zh-Hans/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/fr/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/ru/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/SdkResolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver
/usr/share/dotnet/sdk/6.0.302/SdkResolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.xml
/usr/share/dotnet/sdk/6.0.302/MSBuild.deps.json
/usr/share/dotnet/sdk/6.0.302/ja/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.dll
/usr/share/dotnet/sdk/6.0.302/ko/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/pt-BR/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/de/MSBuild.resources.dll
/usr/share/dotnet/sdk/6.0.302/zh-Hant/MSBuild.resources.dll

I've added /usr/share/dotnet/sdk/6.0.302/ to my PATH but obtained the same error as above.

which linux distro are you running, which architecture?


           `:+shmNNMMNNmhs+:`              emilyseville7cfg@EmilySeville7cfgPC 
        .odMMMMMMMMMMMMMMMMMMdo.           ----------------------------------- 
      /dMMMMMMMMMMMMMMMmMMMMMMMMd/         OS: Ubuntu MATE 22.04.1 LTS x86_64 
    :mMMMMMMMMMMMMNNNNM/`/yNMMMMMMm:       Host: VPCEB4Z1R C608UGVE 
  `yMMMMMMMMMms:..-::oM:    -omMMMMMy`     Kernel: 5.15.0-43-generic 
 `dMMMMMMMMy-.odNMMMMMM:    -odMMMMMMd`    Uptime: 1 hour, 8 mins 
 hMMMMMMMm-.hMMy/....+M:`/yNm+mMMMMMMMh    Packages: 2292 (dpkg), 16 (snap) 
/MMMMNmMN-:NMy`-yNMMMMMmNyyMN:`dMMMMMMM/   Shell: zsh 5.8.1 
hMMMMm -odMMh`sMMMMMMMMMMs sMN..MMMMMMMh   Resolution: 1920x1080 
NMMMMm    `/yNMMMMMMMMMMMM: MM+ mMMMMMMN   DE: MATE 1.26.0 
NMMMMm    `/yNMMMMMMMMMMMM: MM+ mMMMMMMN   WM: Metacity (Marco) 
hMMMMm -odMMh sMMMMMMMMMMs oMN..MMMMMMMh   Theme: Yaru-red [GTK2/3] 
/MMMMNNMN-:NMy`-yNMMMMMNNsyMN:`dMMMMMMM/   Icons: Yaru [GTK2/3] 
 hMMMMMMMm-.hMMy/....+M:.+hNd+mMMMMMMMh    Terminal: kitty 
 `dMMMMMMMMy-.odNMMMMMM:    :smMMMMMMd`    CPU: Intel i5 M 480 (4) @ 2.667GHz 
   yMMMMMMMMMms/..-::oM:    .+dMMMMMy      GPU: AMD ATI Mobility Radeon HD 5650/5750 / 6530M/6550M 
    :mMMMMMMMMMMMMNNNNM: :smMMMMMMm:       Memory: 2085MiB / 3780MiB 
      /dMMMMMMMMMMMMMMMdNMMMMMMMd/
        .odMMMMMMMMMMMMMMMMMMdo.                                   
           `:+shmNNMMNNmhs+:`                                      

which dotnet sdk version are you testing this wit

6.0.302, I've installed it via these instructions.

also -- have you tried installing csharp-ls -- does it behave better/worse/does it not start as well?

image

It works perfectly. 😄

EmilyGraceSeville7cf avatar Aug 07 '22 22:08 EmilyGraceSeville7cf

Why this LSP server requires mono to be installed? Without it server fails with:

omnisharp-roslyn uses "internal" mono to run.. not sure if that is still true with the latest versions. could you check the path where it is installed by lsp-mode -- it should contain the mono binary..

UPDATE -- now I checked -- it does not have that -- omnisharp has changed their distribution contents probably -- will have to update lsp-mode/csharp to install the mono version..

razzmatazz avatar Aug 15 '22 07:08 razzmatazz

It works perfectly. 😄

great! :)

razzmatazz avatar Aug 15 '22 07:08 razzmatazz

Why this LSP server requires mono to be installed? Without it server fails with:

omnisharp-roslyn uses "internal" mono to run.. not sure if that is still true with the latest versions. could you check the path where it is installed by lsp-mode -- it should contain the mono binary..

UPDATE -- now I checked -- it does not have that -- omnisharp has changed their distribution contents probably -- will have to update lsp-mode/csharp to install the mono version..

ok, it seems they changed distribution contents of omnisharp-linux-x64.tar.gz to not supply mono anymore with v1.39.0 release

they also started providing the omnisharp-linux-x64-net6.0.tar.gz which presumably is built with .net 6.0 runtime bundled.. will try to switch to it

razzmatazz avatar Aug 15 '22 07:08 razzmatazz

I created PR #3677 to address omnisharp installation breakage by switching to net6.0-built omnisharp distributions on linux and macOS

razzmatazz avatar Aug 15 '22 09:08 razzmatazz