zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
46.52k stars 2.63k forks source link

Downloaded C# OmniSharp language server does not start #8352

Open atipls opened 6 months ago

atipls commented 6 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

When opening any C# project, Zed tries to download OmniSharp a few times, fails because OmniSharp fails to launch, gives up, meaning no language server features are available. This machine has a standard .NET Core setup for macOS, with a few sdks and runtimes installed, and the project is targeting the latest (8.0.201 as of writing)

atipls@omba % dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.21 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.21 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
atipls@omba % dotnet --list-sdks    
6.0.203 [/usr/local/share/dotnet/sdk]
6.0.413 [/usr/local/share/dotnet/sdk]
7.0.307 [/usr/local/share/dotnet/sdk]
7.0.400 [/usr/local/share/dotnet/sdk]
8.0.201 [/usr/local/share/dotnet/sdk]

Environment

Zed: v0.123.6 (Zed) OS: macOS 14.3.1 Memory: 8 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

2024-02-25T02:01:23+01:00 [ERROR] failed to start language server "OmniSharp": oneshot canceled
2024-02-25T02:01:23+01:00 [ERROR] server stderr: Some("A fatal error occurred. The required library libhostfxr.dylib could not be found.\nIf this is a self-contained application, that library should exist in [/Users/atipls/Library/Application Support/Zed/languages/OmniSharp/].\nIf this is a framework-dependent application, install the runtime in the global location [/usr/local/share/dotnet/x64] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].\n\nThe .NET runtime can be found at:\n  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=arm64&rid=osx.11.3-arm64&apphost_version=6.0.0-preview.7.21317.1\n")
2024-02-25T02:01:23+01:00 [ERROR] crates/lsp/src/lsp.rs:278: Broken pipe (os error 32)
2024-02-25T02:01:23+01:00 [ERROR] crates/lsp/src/lsp.rs:648: server shut down
2024-02-25T02:01:23+01:00 [ERROR] crates/zed/src/languages/csharp.rs:142: no cached binary
2024-02-25T02:01:23+01:00 [INFO] About to spawn test binary
2024-02-25T02:01:23+01:00 [WARN] test binary failed to launch
2024-02-25T02:01:23+01:00 [WARN] test binary check failed
2024-02-25T02:01:23+01:00 [INFO] beginning to reinstall server
2024-02-25T02:01:23+01:00 [INFO] deleting server container
2024-02-25T02:01:23+01:00 [INFO] starting language server "OmniSharp", path: "/Users/atipls/Work/Freezer/MCPE.AlphaServer", id: 4
2024-02-25T02:01:25+01:00 [ERROR] crates/lsp/src/lsp.rs:256: cannot read LSP message headers
2024-02-25T02:01:25+01:00 [ERROR] crates/lsp/src/lsp.rs:648: server shut down
2024-02-25T02:01:25+01:00 [ERROR] crates/lsp/src/lsp.rs:278: Broken pipe (os error 32)
2024-02-25T02:01:25+01:00 [ERROR] failed to start language server "OmniSharp": oneshot canceled
2024-02-25T02:01:25+01:00 [ERROR] server stderr: Some("A fatal error occurred. The required library libhostfxr.dylib could not be found.\nIf this is a self-contained application, that library should exist in [/Users/atipls/Library/Application Support/Zed/languages/OmniSharp/].\nIf this is a framework-dependent application, install the runtime in the global location [/usr/local/share/dotnet/x64] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].\n\nThe .NET runtime can be found at:\n  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=arm64&rid=osx.11.3-arm64&apphost_version=6.0.0-preview.7.21317.1\n")
2024-02-25T02:01:25+01:00 [ERROR] crates/zed/src/languages/csharp.rs:142: no cached binary
2024-02-25T02:01:25+01:00 [INFO] About to spawn test binary
2024-02-25T02:01:25+01:00 [WARN] test binary failed to launch
2024-02-25T02:01:25+01:00 [WARN] test binary check failed
2024-02-25T02:01:25+01:00 [INFO] beginning to reinstall server
2024-02-25T02:01:25+01:00 [INFO] deleting server container
2024-02-25T02:01:25+01:00 [INFO] starting language server "OmniSharp", path: "/Users/atipls/Work/Freezer/MCPE.AlphaServer", id: 5
2024-02-25T02:01:26+01:00 [ERROR] crates/lsp/src/lsp.rs:256: cannot read LSP message headers
2024-02-25T02:01:26+01:00 [ERROR] crates/lsp/src/lsp.rs:278: Broken pipe (os error 32)
2024-02-25T02:01:26+01:00 [ERROR] crates/lsp/src/lsp.rs:648: server shut down
2024-02-25T02:01:26+01:00 [ERROR] failed to start language server "OmniSharp": oneshot canceled
2024-02-25T02:01:26+01:00 [ERROR] server stderr: Some("A fatal error occurred. The required library libhostfxr.dylib could not be found.\nIf this is a self-contained application, that library should exist in [/Users/atipls/Library/Application Support/Zed/languages/OmniSharp/].\nIf this is a framework-dependent application, install the runtime in the global location [/usr/local/share/dotnet/x64] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].\n\nThe .NET runtime can be found at:\n  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=arm64&rid=osx.11.3-arm64&apphost_version=6.0.0-preview.7.21317.1\n")
2024-02-25T02:01:26+01:00 [ERROR] Hit 4 reinstallation attempts for "OmniSharp"
Nefanator commented 6 months ago

I worked around a similar issue by modifying the content of /etc/dotnet/install_location

from "/usr/local/share/dotnet/x64/" to "/usr/local/share/dotnet/"

atipls commented 6 months ago

I worked around a similar issue by modifying the content of /etc/dotnet/install_location

from "/usr/local/share/dotnet/x64/" to "/usr/local/share/dotnet/"

This solved the problem of OmniSharp not starting aswell, so not sure if this as .NET bug or a Zed one, I think the best solution would be if OmniSharp was packaged as a self-contained app, so that it doesn't depend on the system's .NET install

cleissonalves commented 1 month ago

I am using Fedora, but the fix described is not applicable because the path is already correct. Still, Omnisharp does not work.

Zed: v0.143.6 (Zed) OS: Linux Wayland fedora 40 Memory: 31.3 GiB Architecture: x86_64

The C# extension is installed and the Omnisharp is downloaded to: ~/.local/share/zed/extensions/work/csharp/omnisharp-v1.39.11

dotnet --version 9.0.100-preview.5.24307.1 /usr/lib64/dotnet is the installed path /etc/dotnet/install_location content is /usr/lib64/dotnet

The log includes the following:

OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider: OmniSharp requires the .NET 6 SDK or higher be installed. Please visit https://dotnet.microsoft.com/download/dotnet/6.0 to download the .NET SDK.