vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Omnisharp not working on Mac OS M1 and VS Code

Open jcoble opened this issue 2 years ago • 23 comments

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.

jcoble avatar Jun 11 '22 00:06 jcoble

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

JoeRobich avatar Jun 13 '22 21:06 JoeRobich

@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).

jcoble avatar Jun 17 '22 17:06 jcoble

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.

nenright avatar Jun 28 '22 18:06 nenright

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 avatar Jun 28 '22 19:06 harry-patel-jisc

downgrading to v1.24.4 worked for me

harry-patel-jisc avatar Jun 28 '22 20:06 harry-patel-jisc

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

jcoble avatar Jun 28 '22 20:06 jcoble

@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.

JoeRobich avatar Jun 28 '22 23:06 JoeRobich

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

jcoble avatar Jun 29 '22 00:06 jcoble

@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?

JoeRobich avatar Jun 29 '22 01:06 JoeRobich

@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 https://github.com/OmniSharp/omnisharp-roslyn/issues/2412#issuecomment-1163382432

(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.

jcoble avatar Jun 29 '22 02:06 jcoble

@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 https://github.com/OmniSharp/omnisharp-roslyn/issues/2412#issuecomment-1163382432

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.

JoeRobich avatar Jun 29 '22 16:06 JoeRobich

downgrading to v1.24.4 worked for me

Tell me how to downgrade, please ? Thanks !

anhhtca avatar Jul 02 '22 09:07 anhhtca

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.

jcoble avatar Jul 02 '22 09:07 jcoble

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 !

anhhtca avatar Jul 02 '22 09:07 anhhtca

downgrading to v1.24.4 worked for me

It worked for me as well. Thanks!

br-reinaldo-pires avatar Jul 12 '22 13:07 br-reinaldo-pires

downgrading to v1.24.4 worked for me

Worked for me as well.

anup-shetty avatar Aug 30 '22 05:08 anup-shetty

downgrading to v1.24.4 worked for me

proof all heros dont wear capes!

rking-bennie avatar Aug 31 '22 20:08 rking-bennie

downgrading to v1.24.4 worked for me

It worked for me as well!!!

So, it is a bug in the extension right?

sihbher avatar Aug 31 '22 22:08 sihbher

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.

filipw avatar Sep 01 '22 17:09 filipw

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

sihbher avatar Sep 01 '22 20:09 sihbher

@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

JoeRobich avatar Sep 02 '22 16:09 JoeRobich

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

hoangvp-gearinc avatar Sep 12 '22 07:09 hoangvp-gearinc

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

b5stephen avatar Oct 06 '22 21:10 b5stephen

Same issue here, with v1.24.4 worked

seilorjunior avatar Oct 18 '22 00:10 seilorjunior

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

adamholthaus50 avatar Oct 31 '22 00:10 adamholthaus50

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

gestj avatar Nov 01 '22 08:11 gestj

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

MadMacMad avatar Nov 07 '22 11:11 MadMacMad

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 avatar Dec 09 '22 07:12 RbBtSn0w

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 avatar Dec 09 '22 10:12 RbBtSn0w

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)

https://github.com/OmniSharp/omnisharp-vscode/issues/5120

RbBtSn0w avatar Dec 09 '22 10:12 RbBtSn0w