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

lsp-install-server omnisharp fails on macOS #3734

Open
2 of 3 tasks
theschmocker opened this issue Sep 23, 2022 · 13 comments
Open
2 of 3 tasks

lsp-install-server omnisharp fails on macOS #3734

theschmocker opened this issue Sep 23, 2022 · 13 comments
Assignees
Labels

Comments

@theschmocker
Copy link

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • 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

Trying to install omnisharp on macOS fails in 1 of 2 ways:

  1. The download hangs after attempting connection to github
  2. The download "completes" after a long period of time, but the downloaded zip seems corrupted. The file size is much smaller and the unzipped directory is empty

Steps to reproduce

Attempt to install omnisharp using M-x lsp-install-server RET omnisharp RET using Doom Emacs on macOS with Apple Silicon

Expected behavior

I would expect the omnisharp-roslyn.zip archive to have been downloaded fully and for the unzipped directory to contain all of the files from the archive.

Which Language Server did you use?

lsp-csharp -- attempting to download omnisharp

OS

MacOS

Error callstack

When the download hangs, there is no error

When the download does "complete" an error is output saying that the file OmniSharp does not exists when attempting to modify its permissions (because the unzipped directory is empty)

Anything else?

I'm using Doom with Emacs 28.2 (was an issue on 28.1, as well), but I've unpinned lsp-mode and lsp-ui in order to use the latest versions.

Clojure's LSP is downloaded in the same way, AFAICT. It took quite a while, but eventually completed and worked

@yyoncho
Copy link
Member

yyoncho commented Sep 23, 2022

@razzmatazz willing to take a look?

@razzmatazz
Copy link
Collaborator

will do! later today or tommorow

@razzmatazz
Copy link
Collaborator

btw, @theschmocker what platform are you on your mac, intel or apple/m1 ?

@theschmocker
Copy link
Author

Hey @razzmatazz, I'm on an M1

@razzmatazz razzmatazz self-assigned this Sep 24, 2022
@razzmatazz
Copy link
Collaborator

razzmatazz commented Sep 24, 2022

I am using the exact same configuration (doom-emacs + 28.2 + m1) so I should be able to replicate this..

UPDATE: yes, it fails for me too.. curiously messages buffer says:

LSP :: Download omnisharp started.
LSP :: Starting to download https://github.com/omnisharp/omnisharp-roslyn/releases/latest/download/omnisharp-osx-arm64-net6.0.zip to /Users/bob/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn.zip...

but there appears to be no progress whereas downloading the file via browser works..

@razzmatazz
Copy link
Collaborator

razzmatazz commented Sep 24, 2022

hmm, when it does succeed to download, starting OmniSharp fails with:

bob@mbp omnisharp-roslyn % ./OmniSharp 
$ ./OmniSharp 
Failed to load /usr/local/share/dotnet/x64/host/fxr/6.0.8/libhostfxr.dylib, error: dlopen(/usr/local/share/dotnet/x64/host/fxr/6.0.8/libhostfxr.dylib, 0x0001): tried: '/usr/local/share/dotnet/x64/host/fxr/6.0.8/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
The library libhostfxr.dylib was found, but loading it from /usr/local/share/dotnet/x64/host/fxr/6.0.8/libhostfxr.dylib failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=2063366

curiously I do have 6.0.8 runtime installed:

$ dotnet --list-runtimes | grep 6.0.8
Microsoft.AspNetCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

wait a minute.. it is trying to run x64 (intel) binary! what the heck.. because the url to dowload contains omnisharp-osx-arm64-net6.0.zip!

Failed to load /usr/local/share/dotnet/x64/host/fxr/6.0.8/libhostfxr.dylib

@razzmatazz
Copy link
Collaborator

hmm. the file IS arm64 binary..

$ file OmniSharp
OmniSharp: Mach-O 64-bit executable arm64

what is going on.. forcing the OS to run this as arm64 fails too:

arch -arm64 ./OmniSharp 
Failed to load /usr/local/share/dotnet/x64/host/fxr/6.0.8/libhostfxr.dylib, error: dlopen(/usr/local/share/dotnet/x64/host/fxr/6.0.8/libhostfxr.dylib, 0x0001): tried: '/usr/local/share/dotnet/x64/host/fxr/6.0.8/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
The library libhostfxr.dylib was found, but loading it from /usr/local/share/dotnet/x64/host/fxr/6.0.8/libhostfxr.dylib failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=2063366

some googling points me to:

checking things on my machine:

$ cat /etc/dotnet/install_location
/usr/local/share/dotnet/x64
$ cat /etc/dotnet/install_location_arm64 
/usr/local/share/dotnet
$ cat /etc/dotnet/install_location_x64 
/usr/local/share/dotnet/x64

apparently install_location points to x64 for some reason, but this is arm64 machine.. (in issue 27761 they say some dotnet installers previously were setting the files wrong (?!))

tried to do this:

$ sudo cp /private/etc/dotnet/install_location_arm64 /private/etc/dotnet/install_location

and now things started to work somewhat:

bob@mbp omnisharp-roslyn % ./OmniSharp 
./OmniSharp 
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Stdio.Host","Message":"Starting OmniSharp on Unknown 0.0 (Unknown)"},"Seq":1,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Services.DotNetCliService","Message":"Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK"},"Seq":2,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Services.DotNetCliService","Message":"Using the 'dotnet' on the PATH."},"Seq":3,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Services.DotNetCliService","Message":"DotNetPath set to dotnet"},"Seq":4,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.Discovery.MSBuildLocator","Message":"Located 8 MSBuild instance(s)\n            1: .NET Core SDK 6.0.401 17.3.1 - \"/usr/local/share/dotnet/sdk/6.0.401/\"\n            2: .NET Core SDK 6.0.400 17.3.0 - \"/usr/local/share/dotnet/sdk/6.0.400/\"\n            3: .NET Core SDK 6.0.301 17.2.0 - \"/usr/local/share/dotnet/sdk/6.0.301/\"\n            4: .NET Core SDK 6.0.300 17.2.0 - \"/usr/local/share/dotnet/sdk/6.0.300/\"\n            5: .NET Core SDK 6.0.202 17.1.1 - \"/usr/local/share/dotnet/sdk/6.0.202/\"\n            6: .NET Core SDK 6.0.201 17.1.0 - \"/usr/local/share/dotnet/sdk/6.0.201/\"\n            7: .NET Core SDK 6.0.200 17.1.0 - \"/usr/local/share/dotnet/sdk/6.0.200/\"\n            8: .NET Core SDK 6.0.101 17.0.0 - \"/usr/local/share/dotnet/sdk/6.0.101/\""},"Seq":5,"Type":"event"}

lets try reinstalling omnisharp and check if things are better..

@razzmatazz
Copy link
Collaborator

razzmatazz commented Sep 24, 2022

OK, it seems that this helped to make it work.. downloading the server albeit takes weirdly long time, probably DNS or HTTPS setup takes too long on our emacs build (macos/arm)

LSP :: Starting to download https://github.com/omnisharp/omnisharp-roslyn/releases/latest/download/omnisharp-osx-arm64-net6.0.zip to /Users/bob/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn.zip...
Contacting host: github.com:443
Wrote /Users/bob/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn.zip
LSP :: Finished downloading /Users/bob/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn.zip...
(Shell command succeeded with no output)
LSP :: Server omnisharp downloaded, auto-starting in 1 buffers.
LSP :: Guessed project root is ~/src/test-csharp
LSP :: Connected to [omnisharp:8271/starting].
LSP :: omnisharp:8271 initialized successfully in folders: (/Users/bob/src/test-csharp)

which emacs distro are you using @theschmocker, https://github.com/d12frosted/homebrew-emacs-plus ? or something else?

@theschmocker
Copy link
Author

@razzmatazz I am using https://github.com/d12frosted/homebrew-emacs-plus, installed with options --with-elrumo2-icon --with-native-comp

I had a similar issue with OmniSharp and libhostfxr.dylib after installing it manually, but fixed it by setting the DOTNET_ROOT environment variable for my shell like export DOTNET_ROOT="$(dirname $(which dotnet))" and regenerating envvars for doom with doom env

@razzmatazz
Copy link
Collaborator

razzmatazz commented Sep 25, 2022

hmm. but does it start for you now via command line? (once it gets installed properly)

@theschmocker
Copy link
Author

It does:

~/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn (master) » cat /etc/dotnet/install_location
/usr/local/share/dotnet/x64

~/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn (master) » cat /etc/dotnet/install_location_arm64
/usr/local/share/dotnet

~/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn (master) » echo "$DOTNET_ROOT"                                                                     
/usr/local/share/dotnet
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn (master) » ./OmniSharp                                                                             
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Stdio.Host","Message":"Starting OmniSharp on Unknown 0.0 (Unknown)"},"Seq":1,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Services.DotNetCliService","Message":"Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK"},"Seq":2,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Services.DotNetCliService","Message":"DotNetPath set to /usr/local/share/dotnet/dotnet"},"Seq":3,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.Discovery.MSBuildLocator","Message":"Located 1 MSBuild instance(s)\n            1: .NET Core SDK 6.0.400 17.3.0 - \"/usr/local/share/dotnet/sdk/6.0.400/\""},"Seq":4,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.Discovery.MSBuildLocator","Message":"Registered MSBuild instance: .NET Core SDK 6.0.400 17.3.0 - \"/usr/local/share/dotnet/sdk/6.0.400/\""},"Seq":5,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.WorkspaceInitializer","Message":"Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0"},"Seq":6,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectSystem","Message":"No solution files found in '/Users/me/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn'"},"Seq":7,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Script.ScriptProjectSystem","Message":"Detecting CSX files in '/Users/me/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn'."},"Seq":8,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Script.ScriptProjectSystem","Message":"Did not find any CSX files"},"Seq":9,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.WorkspaceInitializer","Message":"Configuration finished."},"Seq":10,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Stdio.Host","Message":"Omnisharp server running using Stdio at location '/Users/me/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn' on host -1."},"Seq":11,"Type":"event"}
{"Event":"started","Body":null,"Seq":12,"Type":"event"}

@razzmatazz
Copy link
Collaborator

mhm.. so the actual issue you're reporting is slow/broken installation process right?

once it is installed it works ok?

@xaiki
Copy link

xaiki commented Jan 19, 2023

looks like it can get closed right ?

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

No branches or pull requests

4 participants