Unable to start OmniSharp in JetBrains Rider

Unable to start OmniSharp in JetBrains Rider

I have SonarLint configured with our SonarCloud installation and all seems well until it hits this error:

Error running SonarLint analysis
java.lang.IllegalStateException: Unable to start OmniSharp
at org.sonarsource.sonarlint.omnisharp.OmnisharpSensor.execute(OmnisharpSensor.java:101)

Environment

.NET SDK (reflecting any global.json):
Version: 5.0.301
Commit: ef17233f86

Runtime Environment:
OS Name: Mac OS X
OS Version: 11.0
OS Platform: Darwin
RID: osx.11.0-x64
Base Path: /usr/local/share/dotnet/sdk/5.0.301/

Host (useful for support):
Version: 5.0.7
Commit: 556582d964

.NET SDKs installed:
2.1.816 [/usr/local/share/dotnet/sdk]
3.1.410 [/usr/local/share/dotnet/sdk]
5.0.301 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.28 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.28 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.28 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
.NET Downloads (Linux, macOS, and Windows)

Full Verbose Log

See atached.
sonar.log (274.3 KB)

t

1 Like

Hello @sagneta,

Thank you for your detailed feedback and welcome to the community!
We will have a closer look at data you provided and will answer here in this topic. It can take some time.
Have a good day!

Hi @sagneta

Thanks for sharing the logs, it is helpful. I see no errors, but we have defined a 1 minute timeout for loading the solution. It seems in your case it takes too much time:

Caused by: java.lang.IllegalStateException: Timeout waiting for solution/project configuration to be loaded

More questions:

  • How big is your solution?
  • Do you have many projects, and/or many dependencies?
  • Anything special about your project (is it a Unity project maybe?).
  • When you look at the SonarLint log tab, can you determine if the OmniSharp process is ā€œstuckā€ or is there some work going on until the 1 minute timeout?
  • Can you try to open your project in VSCode (with the VSCode C# extension) and see if you manage to have intellisense.

Thatā€™s interesting. Itā€™s not a large project. Is there a way of extending the timeout perhaps?

The solution contains 8 projects. There arenā€™t a lot of source files. The projects are .NET core. No UI. Definitely not a Unity project. :slight_smile: It does seem as if everything is running and then suddenly stops. Iā€™m wondering if this timeout is just too low for serious work.

That is part of the feedback we were interesting to receive. There is currently no way for you to increase the timeout, but this is something we can change in the next release.

Except if you can share the project with me, may I ask you to do this test for me:

  1. Download OmniSharp from here
  2. Extract it
  3. Run the command: <omnisharp dir>/run -s <path to your solution.sln>
    And see how long it takes to reach the first log starting by
{"Event":"ProjectAdded"

I would expect that to take more than 1 minute as well, since this is basically what SonarLint is doing under the hood.

Unfortunately the security settings wonā€™t allow me to run the Mono libraries on my laptop.
Thus I canā€™t provide you with the output of the run command.

I can say that we run SonarCloud from CircleCI and the run takes 8 minutes. Not sure if that helps. I can even give you that log output if that helps.

Hi @sagneta,

Then I think this is the root cause of your issue. SonarLint relies on OmniSharp to execute our C# roslyn based analyzer. And so far OmniSharp runs on Mono (I know there are some initiative to move it to .Net Core, but I donā€™t know the ETA).

Any chance you could try to open the same project on a computer with less restriction, and see if that work better?

Oh! Itā€™s the same installation. Indeed, that would cause it. Let me see what I can do.

Ok, I got around the security issue so the run now operates properly. It seems to move quickly to the first Project add. Immediately in fact. However I still get the same timeout within the IDE. Thus I think there is some other issue. :frowning:

Could you please share the full logs of both cases:

  • logs from SonarLint log tab in Rider (the one you provided previously look truncated)
  • logs from command line

I would like to see if the environment is the same, especially the dotnet CLI that is used.

See attached.
idelog.txt (571.0 KB)
omnisharp.txt (2.5 MB)

The SonarLint logs are still truncated (we donā€™t see when OmniSharp starts), but that may be caused by the too numerous occurences of Can't find custom attr constructor image.
Anyway, this is good to know that running OmniSharp standalone loads your project very fast, but not when it is called by SonarLint. I will try to investigate if we are not slowing down the process when consuming the stdio streams.

I was afraid they might be truncated. Sadly thatā€™s all I see.

Hi @sagneta

I tried to reproduce a possible slowness when OmniSharp is producing a lot of logs, but I was not able. Is there any chance you could try to create a reproducer that you could share with me? Maybe try to remove most source code (keep only one dummy class per project) and see if the problem is still there.

I also created a ticket to update OmniSharp to the latest version, but I have no guarantee it will change anything to your problem.

I face the same issue and I can confirm that for me time to get the ā€˜ProjectAddedā€™ event is 2-3 minutes. I guess I have to wait until the timeout will be extended/configurable but would it be an option to actually connect to a running OmniSharp instance somhow?

Unfortunately, I have the same issue. As @Nadarian mentioned for me also ā€˜ProjectAddedā€™ event takes more time to load. Hope you will do sth with that in the near future. We will wait for the information.

Bumpp

Hi folks,

I did some experiment, and managed to have a better understanding of the issue, at least if your problem is related to the size/number of projects in your solution. I created this ticket to track my findings: [SLI-627] Timeout when trying to open big solutions with many projects - SonarSource

I would like to avoid increasing the timeout, since I believe waiting more than 1 minute before getting the first issues reported is not a nice user experience. But maybe this could be a temporary solution.

Ok, but this is NOT a big project. I recall a C# front-end to a Trading System that is an order of magnitude larger. This means for any real C# system this plugin is useless. Thatā€™s basically what this means. Iā€™ll just rely on the build system.

This is the part that I still doesnā€™t understand. Most projects take ~1s to load. But I also encountered some projects that take more than 30s to load, without being able to understand why.
For example Iā€™m testing with this solution:
https://github.com/aws/aws-sdk-net/blob/master/sdk/AWSSDK.NetStandard.sln
that contains 289 projects.

  • all projects but 3 need 1s to load (which is already exceeding the timeout).
  • test/NetStandard/IntegrationTests/IntegrationTests.NetStandard.csproj needs 34s to load
  • test/NetStandard/UnitTests/UnitTests.NetStandard.csproj needs 36s to load
  • test/SmokeTests/AWSSDK.SmokeTests.NetStandard.csproj needs 37s to load

We will continue the investigation and keep you posted.