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

Omnisharp not working on Mac OS M1 and VS Code #5262

Open
jcoble opened this issue Jun 11, 2022 · 36 comments
Open

Omnisharp not working on Mac OS M1 and VS Code #5262

jcoble opened this issue Jun 11, 2022 · 36 comments

Comments

@jcoble
Copy link

jcoble commented Jun 11, 2022

Hi,

I've tried so many suggestions on getting my mac os m1 to work with omni sharp with vs code. Here is the non error log that I get, just that it won't start. Nothing to go on.

Starting OmniSharp server at 6/10/2022, 7:54:04 PM
Target: /Users/jcmac/mainrepos/trackmyhealthmicro/api/trackmyhealthmicro.sln

OmniSharp server started with .NET 6.0.300
.
Path: /Users/jcmac/.vscode-insiders/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.1-beta.2-net6.0/OmniSharp.dll
PID: 63228

[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

Here are the relevant dotnet info

jcmac@Jesses-MacBook-Pro % dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
jcmac@Jesses-MacBook-Pro % dotnet --list-sdks
6.0.300 [/usr/local/share/dotnet/sdk]
jcmac@Jesses-MacBook-Pro % dotnet --version
6.0.300

I can't get any project to work with it. They all work with VS 2022 and Rider. I even put my MB back to factory settings for an unrelated issue and then installed VS 2022 and it still won't. useModerNet is set to true.

I've symlinked sudo ln -s /usr/local/share/dotnet /usr/local/bin/

Not sure where to go from here. The startup limit is set to 180 secs.

I'd appreciate any help you have! Thanks. Oh and I just tried the beta version of omnisharp to see if that would do anything. I'm on VS Code prerelease and regular VS Code, which both are up to date.

@JoeRobich
Copy link
Member

@jcoble If you set the Omnisharp LogLevel to trace in VS Code Settings, are there additional details logged to the OmniSharp Log?

@jcoble
Copy link
Author

jcoble commented Jun 17, 2022

@JoeRobich Ya, I'm still getting the same error. Nothing added onto it to give anymore clue into what it could be.

Starting OmniSharp server at 6/17/2022, 12:27:34 PM
Target: /Users/jcmac/mainrepos/trackmyhealthmicro/api/trackmyhealthmicro.sln

OmniSharp server started with .NET 6.0.300
.
Path: /Users/jcmac/.vscode-insiders/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.1-beta.2-net6.0/OmniSharp.dll
PID: 59382

[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

@nenright
Copy link

not sure if its related or not but I'm seeing this upon installing the extension:

Unhandled exception. System.BadImageFormatException: Could not load file or assembly '/Users/user/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll'. An attempt was made to load a program with an incorrect format.

@harry-patel-jisc
Copy link

harry-patel-jisc commented Jun 28, 2022

i'm getting this too

Starting OmniSharp server at 28/06/2022, 20:50:55
    Target: /Users/harry-patel/Documents/github/jisc/Hesa-Data-Iris/Hesa.Iris.sln

OmniSharp server started with .NET 6.0.300
.
    Path: /Users/harry-patel/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
    PID: 93383

Unhandled exception. System.BadImageFormatException: Could not load file or assembly '/Users/harry-patel/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll'. An attempt was made to load a program with an incorrect format.

File name: '/Users/harry-patel/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll'
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

@harry-patel-jisc
Copy link

downgrading to v1.24.4 worked for me

@jcoble
Copy link
Author

jcoble commented Jun 28, 2022

@harry-patel-jisc Hey! That worked!!!! Finally. Not sure what happened in the latest build but at least it's working now. Thanks Harry!!

@JoeRobich
Copy link
Member

@harry-patel-jisc The error you are seeing typically occurs when you have an x64 build of the .NET SDK installed instead of arm64. To use 1.25.0 you should uninstall your x64 SDK and install the arm64 version.

@jcoble
Copy link
Author

jcoble commented Jun 29, 2022

I have the arm64 version installed. I used visual studio 2022 preview to get everything installed correctly in order to use .net MAUI. I even reformatted back to factory a month back on unrelated issue. I can try again, but there's no way I would be able to do all the other .net 6 things I do especially in Rider. I've never had an error saying I have x64 version installed. I do know that if I had installed the x64 version first a while ago, then installed the arm version, you're supposed to clear both them out then install the arm version.

Runtime Environment:
OS Name: Mac OS X
OS Version: 12.4
OS Platform: Darwin
RID: osx.12-arm64
Base Path: /usr/local/share/dotnet/sdk/6.0.301/

Host (useful for support):
Version: 6.0.6
Commit: 7cca709db2

.NET SDKs installed:
6.0.300 [/usr/local/share/dotnet/sdk]
6.0.301 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.6 [/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.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

❯ dotnet --list-sdks
6.0.300 [/usr/local/share/dotnet/sdk]
6.0.301 [/usr/local/share/dotnet/sdk]

❯ dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.6 [/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.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

❯ dotnet --version
6.0.301

if you see something off here though please let me know.
image

image

Some of these settings I played around with. But I have Rider and VS 2022 preview and am able to create .net MAUI projects along with other .net core solutions, etc. But, I could always be wrong, and I'd sure be mad at myself if I were. Lol

@JoeRobich
Copy link
Member

@jcoble Sorry, yes it appears you are in a different boat. I was speaking to the An attempt was made to load a program with an incorrect format. message in @harry-patel-jisc's omnisharp log.

Looking at your settings nothing jumps out as being problematic. Can you tell me more about the particular project that is failing to load? Is it a MAUI project? If you create a new console app, does the C# extension load when opening it?

@jcoble
Copy link
Author

jcoble commented Jun 29, 2022

@JoeRobich No Worries, so I tried a number of different locations and ways of inputing the sdk location in but now am getting errors! So that helps. (That was after I re-upgraded to the latest version of omni.)

I think this is related to the single quotes not being stripped away like another user OmniSharp/omnisharp-roslyn#2412 (comment)

(this is where I originally had it and think this is correct)

/usr/local/share/dotnet/sdk/6.0.301/

image

(I changed it to here after looking vs 2022's settings)

image

Starting OmniSharp server at 6/28/2022, 10:24:58 PM
Target: /Users/jcmac/Projects/testconsole/testconsole.sln

OmniSharp server started with .NET 6.0.301
(/usr/local/share/dotnet/dotnet).
Path: /Users/jcmac/.vscode-insiders/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
PID: 85205

Assembly loaded: OmniSharp.DotNetTest
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.DotNetTest, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader
Assembly loaded: OmniSharp.Host
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Host, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader
Assembly loaded: OmniSharp.MSBuild
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.MSBuild, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader
Assembly loaded: OmniSharp.Roslyn
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Roslyn, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader
Assembly loaded: OmniSharp.Roslyn.CSharp
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Roslyn.CSharp, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader
Assembly loaded: OmniSharp.Script
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Script, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader
Assembly loaded: OmniSharp.Shared
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Shared, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader
Assembly loaded from path: /Users/jcmac/.vscode-insiders/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.razor/OmniSharpPlugin/Microsoft.AspNetCore.Razor.OmniSharpPlugin.dll
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[dbug]: OmniSharp.CompositionHostBuilder
.NET SDK requires MSBuild instances version 17.0.0 or higher
Could not locate MSBuild instance to register with OmniSharp.
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

But I'm pretty sure the way I had it originally was correct

Sorry, meant to say that I was using a console app made from vs 2022 to test with. And i just went back to the omnisharp last release and everything is working again.

@JoeRobich
Copy link
Member

@jcoble You should not have to enter the sdkPath or sdkVersion unless you want to use a SDK not discoverable from your PATH. If you clear that configuration, is it able to locate your installed SDKs?

I think this is related to the single quotes not being stripped away like another user OmniSharp/omnisharp-roslyn#2412 (comment)

The issue is with the setting descriptions. Let me remove the quotes from the recommended values as they were not intended to part of the value.

@anhhtca
Copy link

anhhtca commented Jul 2, 2022

downgrading to v1.24.4 worked for me

Tell me how to downgrade, please ?
Thanks !

@jcoble
Copy link
Author

jcoble commented Jul 2, 2022

downgrading to v1.24.4 worked for me

Tell me how to downgrade, please ?

Thanks !

Just go to your extensions, find omnisharp, then hit the little gear icon and select install another version(I think that's what it's called). You will see a list of previous versions and just hit 1.24.4. Then reload VS once complete. And that's it. I immediately saw it start to work the logs after I downgraded.

@anhhtca
Copy link

anhhtca commented Jul 2, 2022

downgrading to v1.24.4 worked for me

Tell me how to downgrade, please ?
Thanks !

Just go to your extensions, find omnisharp, then hit the little gear icon and select install another version(I think that's what it's called). You will see a list of previous versions and just hit 1.24.4. Then reload VS once complete. And that's it. I immediately saw it start to work the logs after I downgraded.

It 's worked. Thanks so much !

@br-reinaldo-pires
Copy link

downgrading to v1.24.4 worked for me

It worked for me as well.
Thanks!

@anup-shetty
Copy link

downgrading to v1.24.4 worked for me

Worked for me as well.

@rking-bennie
Copy link

downgrading to v1.24.4 worked for me

proof all heros dont wear capes!

@sihbher
Copy link

sihbher commented Aug 31, 2022

downgrading to v1.24.4 worked for me

It worked for me as well!!!

So, it is a bug in the extension right?

@filipw
Copy link
Contributor

filipw commented Sep 1, 2022

If you get the System.BadImageFormatException it typically means you have an x64 emulated dotnet installed of the native arm64 variant. You should make sure that you install the correct dotnet for your architecture, that arm64 dotnet is accessible from the Code terminal, and then remove the extension and reinstall again to force it to reacquire all the assets.

@sihbher
Copy link

sihbher commented Sep 1, 2022

If you get the System.BadImageFormatException it typically means you have an x64 emulated dotnet installed of the native arm64 variant. You should make sure that you install the correct dotnet for your architecture, that arm64 dotnet is accessible from the Code terminal, and then remove the extension and reinstall again to force it to reacquire all the assets.

At least it's not my case, or so it seems from the terminal. In addition to that if I do the downgrade as recommended, the extension works, not so in the latest version

dotnet info

@JoeRobich
Copy link
Member

@sihbher It could also mean you have the Universal install of VS Code which runs as x64 on Rosetta. This means using the arm64 SDK would throw a BadImageFormatException. I would suggest uninstalling VS Code and be sure to click Apple Silicon when downloading VS Code again (download page).
image

@hoangvp-gearinc
Copy link

downgrading to v1.24.4 worked for me

Tell me how to downgrade, please ?
Thanks !

Just go to your extensions, find omnisharp, then hit the little gear icon and select install another version(I think that's what it's called). You will see a list of previous versions and just hit 1.24.4. Then reload VS once complete. And that's it. I immediately saw it start to work the logs after I downgraded.

It worked, thanks

@b5stephen
Copy link

While I use an M1 Mac, I have to run the x64 version of DotNet due to certain project dependencies not yet supporting ARM.

Downgrading to v1.24.4 worked for me

@seilorjunior
Copy link

Same issue here, with v1.24.4 worked

@adamholthaus50
Copy link

Same issue for me on the Mac M1 using 64 arm version. Downgrade to 1.24.4 seems to have fixed it.

@gestj
Copy link

gestj commented Nov 1, 2022

Same here ... Mac M1, 64arm + downgrade to 1.24.4 worked.

1 similar comment
@MadMacMad
Copy link

Same here ... Mac M1, 64arm + downgrade to 1.24.4 worked.

@RbBtSn0w
Copy link

RbBtSn0w commented Dec 9, 2022

Same here.

Mac M1 Pro

VSCode: 1.74.0 (Universal)

image

Starting OmniSharp on Unknown 0.0 (Unknown)
info: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
info: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[fail]: OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider
The Sdk version specified in the OmniSharp settings was not a valid semantic version. Configured version is ''7.0.100''. Please update your settings and restart OmniSharp.
[fail]: OmniSharp.MSBuild.Discovery.Providers.SdkOverrideInstanceProvider
The Sdk path specified in the OmniSharp settings does not exist. Configured path is ''/usr/local/share/dotnet/sdk/7.0.100''. Please update your settings and restart OmniSharp.
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 0 MSBuild instance(s)
[STDERR] Could not locate MSBuild instance to register with OmniSharp.

@RbBtSn0w
Copy link

RbBtSn0w commented Dec 9, 2022

Same here.

Mac M1 Pro

VSCode: 1.74.0 (Universal)

image

Starting OmniSharp on Unknown 0.0 (Unknown) info: OmniSharp.Services.DotNetCliService Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK info: OmniSharp.Services.DotNetCliService Using the 'dotnet' on the PATH. info: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet [fail]: OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider The Sdk version specified in the OmniSharp settings was not a valid semantic version. Configured version is ''7.0.100''. Please update your settings and restart OmniSharp. [fail]: OmniSharp.MSBuild.Discovery.Providers.SdkOverrideInstanceProvider The Sdk path specified in the OmniSharp settings does not exist. Configured path is ''/usr/local/share/dotnet/sdk/7.0.100''. Please update your settings and restart OmniSharp. info: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 0 MSBuild instance(s) [STDERR] Could not locate MSBuild instance to register with OmniSharp.

By the way, find other way.

workaround:

✅ download this extension version: 1.24.4

@RbBtSn0w
Copy link

RbBtSn0w commented Dec 9, 2022

Same here.
Mac M1 Pro
VSCode: 1.74.0 (Universal)
image
Starting OmniSharp on Unknown 0.0 (Unknown) info: OmniSharp.Services.DotNetCliService Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK info: OmniSharp.Services.DotNetCliService Using the 'dotnet' on the PATH. info: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet [fail]: OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider The Sdk version specified in the OmniSharp settings was not a valid semantic version. Configured version is ''7.0.100''. Please update your settings and restart OmniSharp. [fail]: OmniSharp.MSBuild.Discovery.Providers.SdkOverrideInstanceProvider The Sdk path specified in the OmniSharp settings does not exist. Configured path is ''/usr/local/share/dotnet/sdk/7.0.100''. Please update your settings and restart OmniSharp. info: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 0 MSBuild instance(s) [STDERR] Could not locate MSBuild instance to register with OmniSharp.

By the way, find other way.

workaround:

✅ download this extension version: 1.24.4

Why have this bug? the refactor base dependency.

detail here(On 1.25.0 above)

#5120

@shpsyte
Copy link

shpsyte commented Jan 4, 2023

That's right!

People are downgrading right away, but actually they should installed the right architecture for mac M1 Silicon chip

Arm64 for .net + vscode silicon will work fine

@allisonchou
Copy link
Contributor

Oops - instinctively closed this issue since I thought it was Razor specific. Re-opened. 😄

@sigespweb22
Copy link

downgrading to v1.24.4 worked for me

@davemjones
Copy link

I fought with this for several days. Everything worked great on my Intel MacBook Pro but not on my M1 MacBook Pro. The one change I made that seemed to make the difference was specifying the Omnisharp: Sdk Path in your VSCode settings. I set mine to /usr/local/dotnet

@alexmarmon
Copy link

Switching to the new c# extension from Microsoft is another option for anyone hitting this still. https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit

@ugumerie
Copy link

ugumerie commented Aug 13, 2023

Switching to the new csdevkit would work but the roslyn analyzers stopped working.

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

No branches or pull requests