NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

nuget.exe install fails with confusing error when dependencies are not on -source #4940

Open joelverhagen opened 7 years ago

joelverhagen commented 7 years ago

Tried nuget.exe 4.0.0.

Run this command:

nuget.exe install jver.semver1 -source https://dev.nugettest.org/api/v2 -verbosity detailed

or

nuget.exe install jver.semver1 -source http://api.dev.nugettest.org/v3-index/index.json -verbosity detailed

It fails since jver.semver1 has dependencies that are not on https://dev.nugettest.org/api/v2. This seems reasonable but the error message says that it tried NuGet.org, which has the desired package. Confusing log line:

Unable to resolve dependency 'NETStandard.Library'. Source(s) used: 'nuget.org'.

Full:

Package jver.semver1 from source https://dev.nugettest.org/api/v2 gathered from cache.
  GET https://dev.nugettest.org/api/v2/FindPackagesById()?id='NETStandard.Library'
  OK https://dev.nugettest.org/api/v2/FindPackagesById()?id='NETStandard.Library' 110ms
Total number of results gathered : 3
Gathering dependency information took 150.83 ms
Summary of time taken to gather dependencies per source :
C:\Users\jver\Desktop\repro     -       7.14 ms
https://dev.nugettest.org/api/v2        -       118.11 ms
Attempting to resolve dependencies for package 'jver.semver1.1.0.0' with DependencyBehavior 'Lowest'
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Unable to resolve dependency 'NETStandard.Library'. Source(s) used: 'nuget.org'. ---> NuGet.Resolver.NuGetResolverConstraintException: Unable to resolve dependency 'NETStandard.Library'. Source(s) used: 'nuget.org'.
   at NuGet.Resolver.PackageResolver.Resolve(PackageResolverContext context, CancellationToken token)
   at NuGet.PackageManagement.NuGetPackageManager.<PreviewInstallPackageAsync>d__65.MoveNext()
   --- End of inner exception stack trace ---
   at NuGet.PackageManagement.NuGetPackageManager.<PreviewInstallPackageAsync>d__65.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<InstallPackageAsync>d__48.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.InstallCommand.<InstallPackage>d__30.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at NuGet.CommandLine.Command.Execute()
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
---> (Inner Exception #0) System.InvalidOperationException: Unable to resolve dependency 'NETStandard.Library'. Source(s) used: 'nuget.org'. ---> NuGet.Resolver.NuGetResolverConstraintException: Unable to resolve dependency 'NETStandard.Library'. Source(s) used: 'nuget.org'.
   at NuGet.Resolver.PackageResolver.Resolve(PackageResolverContext context, CancellationToken token)
   at NuGet.PackageManagement.NuGetPackageManager.<PreviewInstallPackageAsync>d__65.MoveNext()
   --- End of inner exception stack trace ---
   at NuGet.PackageManagement.NuGetPackageManager.<PreviewInstallPackageAsync>d__65.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<InstallPackageAsync>d__48.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.InstallCommand.<InstallPackage>d__30.MoveNext()<---

If the package is already in the global packages folder, specifying the version explicitly works:

nuget.exe install jver.semver1 -version 1.0.0 -source https://dev.nugettest.org/api/v2 -verbosity detailed
joelverhagen commented 7 years ago

Log without -verbosity Detailed:

Feeds used:
  https://dev.nugettest.org/api/v2

  GET https://dev.nugettest.org/api/v2/FindPackagesById()?id='jver.semver1'
  OK https://dev.nugettest.org/api/v2/FindPackagesById()?id='jver.semver1' 113ms

Attempting to gather dependency information for package 'jver.semver1.1.0.0' with respect to project 'C:\Users\jver\Downloads\test', targeting 'Any,Version=v0.0'
Gathering dependency information took 144.86 ms
Attempting to resolve dependencies for package 'jver.semver1.1.0.0' with DependencyBehavior 'Lowest'
Unable to resolve dependency 'NETStandard.Library'. Source(s) used: 'nuget.org'.
rrelyea commented 7 years ago

@zhili1208 - this sounds similar to the 4.1 fix we did in VSIX. Same issue?

rrelyea commented 7 years ago

@joelverhagen - did this work before? in what version? (remove semver from your repro?)

joelverhagen commented 7 years ago

@rrelyea, I did not try older versions. SemVer version has nothing to do with this. This is a typical old SemVer 1.0.0 package.

joelverhagen commented 7 years ago

Oh wait, I did try latest dev build. Still reproes.

rrelyea commented 7 years ago

@zhili1208 - if this worked in 3.5, we'd want to discuss a fix for 4.1.

emgarten commented 7 years ago

The 4.1 fix was around checking licenses which would not be part of command line.

👍 on fixing this for the next release.

zhili1208 commented 7 years ago

Per rob, moving to future-0

ghost commented 6 years ago

Any update on this? Still getting the error with 4.4.1

nuget install System.IO.Compression.Brotli ^
  -source https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json ^
  -Prerelease
ghost commented 6 years ago

Ok seems to work if we provide additonal source:

nuget install System.IO.Compression.Brotli ^
  -source https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json ^
  -source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json ^
  -output deps ^
  -Prerelease
daveaglick commented 5 years ago

Just hit this and spent several hours chasing the wrong problem given the totally incorrect error message:

Unable to resolve dependency 'Foo'. Source(s) used: 'nuget.org', 'File System', 'Microsoft Visual Studio Offline Packages'.