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

New dependency resolver does not properly detect a cycle with a transitive dependency with the same name as the root project #14052

Open
JohanLarsson opened this issue Jan 18, 2025 · 2 comments · May be fixed by NuGet/NuGet.Client#6247
Assignees
Labels
Area:NewDependencyResolver Issues related to the new dependency graph resolver Category:Quality Week Issues that should be considered for quality week Priority:2 Issues for the current backlog. SeQuality Type:Bug
Milestone

Comments

@JohanLarsson
Copy link

JohanLarsson commented Jan 18, 2025

NuGet Product Used

dotnet.exe

Product Version

9.0.0

Worked before?

Assume no

Impact

It's more difficult to complete my work

Repro Steps & Context

  1. Name a project LightGbm
  2. Try to install https://www.nuget.org/packages/Microsoft.ML.LightGbm

It fails with message 'the given key was not present in the dictionary'

Image

This is happening because a transitive dependency has the same name as the root project and the new dependency resolver tries to replace the root project with it instead of just ignoring it for later since it needs to be detected as a cycle instead.

Verbose Logs

@jeffkl
Copy link
Contributor

jeffkl commented Jan 21, 2025

Thank you for reporting this issue. This is caused by a bug in the new dependency resolver. It should be informing you of a cycle and if you use the legacy dependency resolver you get the proper error message:

error NU1108: Cycle detected.
error NU1108:   LightGbm -> Microsoft.ML.LightGbm 4.0.1 -> LightGBM (>= 3.3.5)

You would not be able to install a package with a transitive dependency with the same name as your project so you'll need to rename your project. To workaround the issue, you can also enable the legacy dependency resolver: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#nuget-dependency-resolver

@jeffkl jeffkl changed the title Install package into project with similar name fails New dependency resolver does not properly detect a cycle with a transitive dependency with the same name as the root project Jan 21, 2025
@jeffkl jeffkl added Priority:2 Issues for the current backlog. Area:NewDependencyResolver Issues related to the new dependency graph resolver and removed Triage:Untriaged labels Jan 21, 2025
@jeffkl jeffkl self-assigned this Jan 21, 2025
@jeffkl
Copy link
Contributor

jeffkl commented Jan 27, 2025

This was technically fixed in NuGet/NuGet.Client#6231 but only by accident. I might still need to fix it intentionally.

@jeffkl jeffkl added the Category:Quality Week Issues that should be considered for quality week label Jan 27, 2025
@jeffkl jeffkl added this to the 6.14 milestone Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:NewDependencyResolver Issues related to the new dependency graph resolver Category:Quality Week Issues that should be considered for quality week Priority:2 Issues for the current backlog. SeQuality Type:Bug
Projects
None yet
3 participants