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

System.IndexOutOfRangeException in OmniSharp.Utilities.PlatformHelper.GetMonoVersion #2651

Open
rene-descartes2021 opened this issue Jan 28, 2025 · 1 comment

Comments

@rene-descartes2021
Copy link

rene-descartes2021 commented Jan 28, 2025

Error on download and run:

$ wget https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.13/omnisharp-linux-arm64.tar.gz
$ tar xzvf omnisharp-linux-arm64.tar.gz
$ ./run
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Stdio.Host","Message":"Starting OmniSharp on Linux 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 /data/data/com.termux/files/usr/lib/dotnet/dotnet"},"Seq":3,"Type":"event"}
System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at OmniSharp.Utilities.PlatformHelper.GetMonoVersion () [0x0002b] in <2e4943dec5344e2085e51702e281221a>:0
  at OmniSharp.MSBuild.Discovery.Providers.MonoInstanceProvider.GetInstances () [0x0009d] in <6714f554c80a4f15b10f9d1a07514fee>:0
  at OmniSharp.MSBuild.Discovery.MSBuildLocator.GetInstances () [0x0001b] in <6714f554c80a4f15b10f9d1a07514fee>:0
  at OmniSharp.MSBuild.Discovery.Extensions.GetBestInstance (OmniSharp.MSBuild.Discovery.IMSBuildLocator msbuildLocator, System.Version minimumMSBuildVersion, Microsoft.Extensions.Logging.ILogger logger, System.Boolean& invalidVSFound, System.Boolean& vsWithoutSdkResolver) [0x0000b] in <6714f554c80a4f15b10f9d1a07514fee>:0
  at OmniSharp.MSBuild.Discovery.Extensions.RegisterDefaultInstance (OmniSharp.MSBuild.Discovery.IMSBuildLocator msbuildLocator, Microsoft.Extensions.Logging.ILogger logger, OmniSharp.Services.DotNetInfo dotNetInfo) [0x0001e] in <6714f554c80a4f15b10f9d1a07514fee>:0
  at OmniSharp.CompositionHostBuilder.Build (System.String workingDirectory) [0x000ad] in <6714f554c80a4f15b10f9d1a07514fee>:0
  at OmniSharp.Stdio.Host..ctor (System.IO.TextReader input, OmniSharp.Services.ISharedTextWriter writer, OmniSharp.IOmniSharpEnvironment environment, System.IServiceProvider serviceProvider, OmniSharp.CompositionHostBuilder compositionHostBuilder, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Threading.CancellationTokenSource cancellationTokenSource) [0x00065] in <a21b7804648c4a68a8724e9af77e2540>:0
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x0017d] in <41ffe59c485749dfa5a695f894515abf>:0
  at OmniSharp.CommandLineApplication+<>c__DisplayClass12_0.<OnExecute>b__0 () [0x0000b] in <6714f554c80a4f15b10f9d1a07514fee>:0
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication+<>c__DisplayClass143_0.<OnExecute>b__0 (System.Threading.CancellationToken _) [0x00000] in <21ffa10636d3445095cca7f9fdee08c0>:0
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync (System.String[] args, System.Threading.CancellationToken cancellationToken) [0x000ba] in <21ffa10636d3445095cca7f9fdee08c0>:0
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00016] in <21ffa10636d3445095cca7f9fdee08c0>:0
  at OmniSharp.CommandLineApplication.Execute (System.String[] args) [0x00081] in <6714f554c80a4f15b10f9d1a07514fee>:0
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <41ffe59c485749dfa5a695f894515abf>:0
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <6714f554c80a4f15b10f9d1a07514fee>:0

The omnisharp-linux-arm64-net6.0 (non-portable build?) won't work for me as that is glibc. I am using bionic libc. So I tried what I expect to be the portable build omnisharp-linux-arm64.

I believe I am using the "Linux Bionic Arm64 NativeAOT" vertical build of dotnet. I'm probably among the first to try using OmniSharp with this. It was compiled with --use-mono-runtime even though it targets linux-bionic, I'm really not sure how things work there with both Mono and CoreCLR.

Oh, I just noticed mono --version doesn't print anything or error and it should?:

$  mono --version
$  echo $?
0

Here is dotnet info:

$  dotnet --info
.NET SDK:
 Version:           8.0.112
 Commit:            3f0c4a16e5
 Workload version:  8.0.100-manifests.784cc8f7

Runtime Environment:
 OS Name:     Linux
 OS Version:
 OS Platform: Linux
 RID:         linux-bionic-arm64
 Base Path:   /data/data/com.termux/files/usr/lib/dotnet/sdk/8.0.112/

.NET workloads installed:
 Workload version: 8.0.100-manifests.784cc8f7
There are no installed workloads to display.

Host:
  Version:      8.0.12
  Architecture: arm64
  Commit:       89ef51c5d8

.NET SDKs installed:
  8.0.112 [/data/data/com.termux/files/usr/lib/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.12 [/data/data/com.termux/files/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.12 [/data/data/com.termux/files/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/data/data/com.termux/files/usr/lib/dotnet]

Well any diagnostics I can try let me know. Might not be OmniSharp? Maybe dotnet was built with an unexpected problem by the Termux distro maintainer?

I plan to try to build a non-portable release of Omnisharp (for bionic libc) and see how that goes.

Thank you for looking and have a nice day.

@rene-descartes2021 rene-descartes2021 changed the title System.IndexOutOfRangeException in OmniSharp.Utilities.PlatformHelper.GetMonoVersion System.IndexOutOfRangeException in OmniSharp.Utilities.PlatformHelper.GetMonoVersion Jan 28, 2025
@rene-descartes2021
Copy link
Author

Oh.. looking around in the issues I see that the net6 release should be used as dotnet OmniSharp.dll.

I'd initially just looked at what I expect to see when something uses glibc:

$  ldd OmniSharp
        libpthread.so.0 => not found
        libdl.so.2 => not found
        libstdc++.so.6 => not found
        libm.so.6 => not found
        libgcc_s.so.1 => not found
        libc.so.6 => not found
        ld-linux-aarch64.so.1 => not found

However I get a different error now with dotnet OmniSharp.dll from the net6 release:

$  dotnet OmniSharp.dll
{"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 /data/data/com.termux/files/usr/lib/dotnet/dotnet"},"Seq":3,"Type":"event"}
System.Runtime.InteropServices.MarshalDirectiveException: Array size control parameter must be an integral type.
   at Microsoft.Build.Locator.DotNetSdkLocationHelper.GetAllAvailableSDKs()
   at Microsoft.Build.Locator.DotNetSdkLocationHelper.GetDotNetBasePaths(String workingDirectory)+MoveNext()
   at Microsoft.Build.Locator.DotNetSdkLocationHelper.GetInstances(String workingDirectory)+MoveNext()
   at Microsoft.Build.Locator.MSBuildLocator.GetInstances(VisualStudioInstanceQueryOptions options)+MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1[[Microsoft.Build.Locator.VisualStudioInstance, Microsoft.Build.Locator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9dff12846e04bfbd]].ToArray()
   at System.Linq.Buffer`1[[Microsoft.Build.Locator.VisualStudioInstance, Microsoft.Build.Locator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9dff12846e04bfbd]]..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1[[Microsoft.Build.Locator.VisualStudioInstance, Microsoft.Build.Locator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9dff12846e04bfbd]].ToArray()
   at System.Linq.Enumerable.ToArray[VisualStudioInstance](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[VisualStudioInstance](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[VisualStudioInstance](IEnumerable`1 items)
   at OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider.GetInstances() in /home/vsts/work/1/s/src/OmniSharp.Host/MSBuild/Discovery/Providers/SdkInstanceProvider.cs:line 33
   at OmniSharp.MSBuild.Discovery.MSBuildLocator.GetInstances() in /home/vsts/work/1/s/src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs:line 120
   at OmniSharp.MSBuild.Discovery.Extensions.GetBestInstance(IMSBuildLocator msbuildLocator, Version minimumMSBuildVersion, ILogger logger, Boolean& invalidVSFound, Boolean& vsWithoutSdkResolver) in /home/vsts/work/1/s/src/OmniSharp.Host/MSBuild/Discovery/Extensions.cs:line 84
   at OmniSharp.MSBuild.Discovery.Extensions.RegisterDefaultInstance(IMSBuildLocator msbuildLocator, ILogger logger, DotNetInfo dotNetInfo) in /home/vsts/work/1/s/src/OmniSharp.Host/MSBuild/Discovery/Extensions.cs:line 17
   at OmniSharp.CompositionHostBuilder.Build(String workingDirectory) in /home/vsts/work/1/s/src/OmniSharp.Host/CompositionHostBuilder.cs:line 68
   at OmniSharp.Stdio.Host..ctor(TextReader input, ISharedTextWriter writer, IOmniSharpEnvironment environment, IServiceProvider serviceProvider, CompositionHostBuilder compositionHostBuilder, ILoggerFactory loggerFactory, CancellationTokenSource cancellationTokenSource) in /home/vsts/work/1/s/src/OmniSharp.Stdio/Host.cs:line 49
   at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1() in /home/vsts/work/1/s/src/OmniSharp.Stdio.Driver/Program.cs:line 74
   at OmniSharp.CommandLineApplication.<>c__DisplayClass12_0.<OnExecute>b__0() in /home/vsts/work/1/s/src/OmniSharp.Host/CommandLineApplication.cs:line 92
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at OmniSharp.CommandLineApplication.Execute(String[] args) in /home/vsts/work/1/s/src/OmniSharp.Host/CommandLineApplication.cs:line 65
   at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_0.<Main>b__0() in /home/vsts/work/1/s/src/OmniSharp.Stdio.Driver/Program.cs:line 84
   at OmniSharp.HostHelpers.Start(Func`1 action) in /home/vsts/work/1/s/src/OmniSharp.Host/HostHelpers.cs:line 30

I guess I should just try building OmniSharp in this environment and see how that goes.

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

No branches or pull requests

1 participant