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

Hang when attempting to index NodaTime #48

Open
varungandhi-src opened this issue Oct 18, 2023 · 2 comments
Open

Hang when attempting to index NodaTime #48

varungandhi-src opened this issue Oct 18, 2023 · 2 comments

Comments

@varungandhi-src
Copy link
Contributor

varungandhi-src commented Oct 18, 2023

Repro steps:

git clone https://github.com/nodatime/nodatime
cd nodatime && git checkout c6158de491e041c07a8a12147676e57683302554
docker run -v $(pwd):/app sourcegraph/scip-dotnet:latest scip-dotnet index src/NodaTime.sln

scip-dotnet image hash: a4b074f00f73

Output:

❯ docker run -v $(pwd):/app sourcegraph/scip-dotnet:latest scip-dotnet index src/NodaTime.sln
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
04:28:15 info: ScipDotnet.IndexCommandOptions[0] $ dotnet restore /app/src/NodaTime.sln /p:EnableWindowsTargeting=true
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'restore' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible .NET SDK was not found.

Requested SDK version: 6.0.200
global.json file: /app/global.json

Installed SDKs:

Install the [6.0.200] .NET SDK or update [/app/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
7.0.305 [/usr/share/dotnet/sdk]
A compatible .NET SDK was not found.

Requested SDK version: 6.0.200
global.json file: /app/global.json

Installed SDKs:

Install the [6.0.200] .NET SDK or update [/app/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found

After this, it seems like it just gets stuck.

@varungandhi-src
Copy link
Contributor Author

When using scip-dotnet installed globally on Linux (the previous approach was using Docker on macOS), I got a more useful stack trace.

I'm guessing this is related to this .NET version bit in the README

Note that scip-dotnet is built against .NET 7.0 and won't run with older versions

nodatime is a pretty popular library, so it'd be nice if we could index it out-of-the-box.

Unhandled exception: System.InvalidOperationException: Failed to find an appropriate version of .NET Core MSBuild. Call to hostfxr_resolve_sdk2 failed. There may be more details in stderr.
   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.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults()
   at ScipDotnet.Program.CreateWorkspace() in /home/runner/work/scip-dotnet/scip-dotnet/ScipDotnet/Program.cs:line 74
   at ScipDotnet.Program.<>c.<Main>b__0_11(IServiceProvider _) in /home/runner/work/scip-dotnet/scip-dotnet/ScipDotnet/Program.cs:line 62
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at ScipDotnet.ScipIndexer.IndexProject(IHost host, IndexCommandOptions options, FileInfo rootProject, HashSet`1 indexedProjects)+MoveNext() in /home/runner/work/scip-dotnet/scip-dotnet/ScipDotnet/ScipIndexer.cs:line 55
   at ScipDotnet.ScipIndexer.IndexProject(IHost host, IndexCommandOptions options, FileInfo rootProject, HashSet`1 indexedProjects)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at ScipDotnet.ScipIndexer.IndexDocuments(IHost host, IndexCommandOptions options)+MoveNext() in /home/runner/work/scip-dotnet/scip-dotnet/ScipDotnet/ScipIndexer.cs:line 44
   at ScipDotnet.ScipIndexer.IndexDocuments(IHost host, IndexCommandOptions options)+MoveNext() in /home/runner/work/scip-dotnet/scip-dotnet/ScipDotnet/ScipIndexer.cs:line 44
   at ScipDotnet.ScipIndexer.IndexDocuments(IHost host, IndexCommandOptions options)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at ScipDotnet.IndexCommandHandler.ScipIndex(IHost host, IndexCommandOptions options) in /home/runner/work/scip-dotnet/scip-dotnet/ScipDotnet/IndexCommandHandler.cs:line 64
   at ScipDotnet.IndexCommandHandler.ScipIndex(IHost host, IndexCommandOptions options) in /home/runner/work/scip-dotnet/scip-dotnet/ScipDotnet/IndexCommandHandler.cs:line 64
   at ScipDotnet.IndexCommandHandler.Process(IHost host, List`1 projects, String output, FileInfo workingDirectory, List`1 include, List`1 exclude, Boolean allowGlobalSymbolDefinitions) in /home/runner/work/scip-dotnet/scip-dotnet/ScipDotnet/IndexCommandHandler.cs:line 38
   at System.CommandLine.NamingConventionBinder.CommandHandler.GetExitCodeAsync(Object returnValue, InvocationContext context)
   at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Hosting.HostingExtensions.<>c__DisplayClass1_0.<<UseHost>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()

@olafurpg
Copy link
Member

@varungandhi-src Thank you for reporting! The root issue seems to be the docker container. I was able to index NodaTime through docker by using the following steps

❯ docker run -v $(pwd):/app -it mcr.microsoft.com/dotnet/sdk:6.0 /bin/bash
Unable to find image 'mcr.microsoft.com/dotnet/sdk:6.0' locally
6.0: Pulling from dotnet/sdk
85e50d2242ce: Already exists
a8f397a9d88b: Already exists
b8c2cdced2f5: Already exists
ab2bdbb6e9d1: Already exists
60e640906191: Already exists
fceb1d07528f: Already exists
f2e226c5445c: Already exists
2e2d3fda3c46: Already exists
Digest: sha256:1167d21bf2d6b0aeb9fce863a73e90defa9233574b74d9deabee0a714f15c951
Status: Downloaded newer image for mcr.microsoft.com/dotnet/sdk:6.0
root@3aafa9b866bb:/# export PATH="$PATH:/root/.dotnet/tools"
root@3aafa9b866bb:/# dotnet tool install --global scip-dotnet
You can invoke the tool using the following command: scip-dotnet
Tool 'scip-dotnet' (version '0.2.4') was successfully installed.
root@3aafa9b866bb:/# cd app
root@3aafa9b866bb:/app# scip-dotnet index src/NodaTime.sln
09:35:55 info: ScipDotnet.IndexCommandOptions[0] $ dotnet restore /app/src/NodaTime.sln /p:EnableWindowsTargeting=true
  Determining projects to restore...
  Restored /app/src/NodaTime.Tools.ValidateHistoricalNzd/NodaTime.Tools.ValidateHistoricalNzd.csproj (in 1.34 sec).
  Restored /app/src/NodaTime.Tools.DumpTimeZoneInfo/NodaTime.Tools.DumpTimeZoneInfo.csproj (in 1.34 sec).
  Restored /app/src/NodaTime.Tools.Common/NodaTime.Tools.Common.csproj (in 1.35 sec).
  Restored /app/src/NodaTime.Testing/NodaTime.Testing.csproj (in 1.35 sec).
  Restored /app/src/NodaTime/NodaTime.csproj (in 14 ms).
  Restored /app/src/NodaTime.NzdPrinter/NodaTime.NzdPrinter.csproj (in 312 ms).
  Restored /app/src/NodaTime.TzdbCompiler/NodaTime.TzdbCompiler.csproj (in 842 ms).
  Restored /app/src/NodaTime.TzValidate.NodaDump/NodaTime.TzValidate.NodaDump.csproj (in 884 ms).
  Restored /app/src/NodaTime.TzdbCompiler.Test/NodaTime.TzdbCompiler.Test.csproj (in 2.98 sec).
  Restored /app/src/NodaTime.TzValidate.NzdCompatibility/NodaTime.TzValidate.NzdCompatibility.csproj (in 4.76 sec).
  Restored /app/src/NodaTime.Demo/NodaTime.Demo.csproj (in 3.02 sec).
  Restored /app/src/NodaTime.Benchmarks/NodaTime.Benchmarks.csproj (in 3.09 sec).
  Restored /app/src/NodaTime.Test/NodaTime.Test.csproj (in 5.13 sec).
09:36:24 info: ScipDotnet.IndexCommandOptions[0] done: /app/index.scip 29s

The root problem is that the scip-dotnet docker container includes net7.0 when nodatime requires net6.0. We cross-build scip-dotnet for both net7.0 and net6.0, but it seems you have to have net6.0 installed to build the nodatime codebase.

@linear linear bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
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

2 participants