emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.77k stars 883 forks source link

Trying to run lsp-mode to edit csharp projects with omnisharp on cygwin's emacs, not supported. #3510

Open programingfrik opened 2 years ago

programingfrik commented 2 years ago

Thank you for the bug report

Bug description

Running lsp-mode on any csharp project with omnisharp on cygwin's emacs is not supported, doesn't work.

Steps to reproduce

Just:

Expected behavior

I expect lsp-mode to work, to display the completion option in some kind of text-based context menu, and the hints, and the help and all the stuff.

Which Language Server did you use?

lsp-csharp with omnisharp.

OS

Windows

Error callstack

*lsp-log*
Found the following clients for /home/progr/prueba/prueba.cs: (server-id omnisharp, priority -1)
The following clients were selected based on priority: (server-id omnisharp, priority -1)

*Messages*
LSP :: Connected to [omnisharp:882/starting].
LSP :: omnisharp has exited (exited abnormally with code 2)
Server omnisharp:882/starting exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n) n

*omnisharp::stderr*
Cannot open assembly '/home/progr/.emacs.d/.cache/lsp/omnisharp-roslyn/latest/omnisharp-roslyn/OmniSharp.exe': No such file or directory.

Process omnisharp stderr finished

*lsp-log: omnisharp:882*
[Trace - 12:16:17 AM] Sending request 'initialize - (3)'.
Params: {
  "processId": null,
  "rootPath": "/home/progr/prueba",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 28.1 (build 1, x86_64-pc-cygwin)\n of 2022-04-05"
  },
  "rootUri": "file:///home/progr/prueba",
  "capabilities": {
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },
      "applyEdit": true,
      "symbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
...

All other special buffers where empty.

Anything else?

I made an attempt to modify some parts of lsp-mode.el to make it work under cygwin, got it to install omnisharp, but didn't work. Modified a bit more, got it to install windows specific version, but it didn't work either. Tried to install omnisharp for windows specific versions including the one for .net 6 (the one that I have installed) didn't work either. I also have mono installed since it tried to run omnisharp through mono.

yyoncho commented 2 years ago

@razzmatazz - any clue?

razzmatazz commented 2 years ago

@programingfrik it is hard for me to diagnose anything, but this says:

that omnisharp.exe cannot be found on the given path.. have you setup path forwarding correctly on cygwin?

also, may I suggest you try csharp-ls? :) not sure if that will help, but that uses dotnet tool mechanism and may work better if you have dotnet on your $PATH in emacs

programingfrik commented 2 years ago

By what I've seen so far in the parts that I've been touching, lsp-mode doesn't take into account cygwin. I don't see any "(eq system-type cygwin)" condition. Cygwin is windows but it handles the paths a la unix, so for example when lsp-mode tries to unzip the downloaded omnisharp binary it sees the powershell command and tries to use it to extract the zip file, but it calls powershell with a unix path that it doesn't understands. I solved that part putting a condition in front of the condition trying to find powershell that if it is running on cygwin to avoid using porwershell. An alternative would've been using cygpath to translate the path. I think the parts of the project that interact with the file system in some way need to be aware of cygwin. Maybe this should be feature request "support cygwin" as a platform. :-P

razzmatazz commented 2 years ago

Obviously it is not for me to urge any changes to your dev environment, but i believe WSL/WSL2 would work better for you in this case and w/o much hacking of lsp-mode out of the box..

programingfrik commented 2 years ago

Well I have tried csharp-ls but it didn't work out of the box either and I didn't put much effort on seeing what was missing. I can give it another more serious try. I can also give a try to WSL. In the end is more of a whim to use omnisharp on this setting, I already use visual studio for serious work. I'll report back any news.

jdrst commented 2 years ago

this might help.