[stable] Fix #2973: [Reg] error when depending on a subpackages that is already resolved#2974
[stable] Fix #2973: [Reg] error when depending on a subpackages that is already resolved#2974Geod24 merged 4 commits intodlang:stablefrom
Conversation
|
✅ PR OK, no changes in deprecations or warnings Total deprecations: 8 Total warnings: 0 Build statistics: statistics (-before, +after)
-executable size=5293368 bin/dub
-rough build time=62s
+executable size=5297464 bin/dub
+rough build time=61sFull build output |
source/dub/project.d
Outdated
| assert(range.isExactVersion()); | ||
| return m_packageManager.getPackage(dep.name, vspec.version_); | ||
| auto tmp = m_packageManager.getPackage(basename, vspec.version_); | ||
| return resolveSubPackage(tmp, subname, true); |
There was a problem hiding this comment.
This fixes the testcase in #2973. Not sure if this is the right fix though; PackageManager.getPackage() returning the parent package when given a subpackage name doesn't make a lot of sense IMO.
There was a problem hiding this comment.
Yeah it doesn't make a lot of sense but it's always been this way. It was one of the things I wanted to fix when I introduced PackageName but never got around to it.
For dependency resolution we always store references to parent package, not subpackage, because all subpackages should resolve to the same parent. I would need to inspect the code to see if that is really the right fix.
There was a problem hiding this comment.
Okay fine if it's always been like that.
| assert(dub.project.getDependency("b", true), "Missing 'b' dependency"); | ||
| assert(dub.project.getDependency("c", true), "Missing 'c' dependency"); | ||
| assert(dub.project.getDependency("c", true), "Missing 'd' dependency"); | ||
| assert(dub.project.getDependency("d", true), "Missing 'd' dependency"); |
There was a problem hiding this comment.
Just happened to notice this while browsing the tests.
Geod24
left a comment
There was a problem hiding this comment.
Thanks! By when do you need this reviewed ?
source/dub/project.d
Outdated
| assert(range.isExactVersion()); | ||
| return m_packageManager.getPackage(dep.name, vspec.version_); | ||
| auto tmp = m_packageManager.getPackage(basename, vspec.version_); | ||
| return resolveSubPackage(tmp, subname, true); |
There was a problem hiding this comment.
Yeah it doesn't make a lot of sense but it's always been this way. It was one of the things I wanted to fix when I introduced PackageName but never got around to it.
For dependency resolution we always store references to parent package, not subpackage, because all subpackages should resolve to the same parent. I would need to inspect the code to see if that is really the right fix.
I assume you've already reviewed this, and if you haven't, just expand the diff context - all other branches do the subpackage resolution (after getting the base package). :) - This is IMO a major release blocker, so v1.39 final should definitely have this. |
| `{ "fileVersion": 1, "versions": { "b": "1.0.0" } }`); | ||
| root.writePackageFile("b", "1.0.0", | ||
| `{ "name": "b", "version": "1.0.0", "subPackages": [ { "name": "a" } ] }`); | ||
| }); |
There was a problem hiding this comment.
Btw thx again for the test framework, sooo much better than the old tests...
There was a problem hiding this comment.
I wish we had a similar filesystem abstract in Phobos to make this kind of unittests the norm. It is so much more expressive.
I really need to finish it though, there's an issue with Windows at the moment which prevents mimicking the real world properly.
Do you know what introduced the regression ? I am fairly sure it used to work ? |
Oh, I thought this was all revamped after v1.38, but no, the 'problematic' line is the same as was in v1.38.0, which works for the original test case. Hmm... |
|
Hmm, this looks suspicious: dub/source/dub/packagemanager.d Lines 1740 to 1747 in 7a50f4c It returns the package from the |
| } | ||
|
|
||
| return null; | ||
| } |
There was a problem hiding this comment.
I've totally reworked the fix, tackling the PackageManager API instead and resolving the subpackage in the lazy-loading getPackage() case (that was the regression AFAICT), as well as newly in loadSCMPackage().
With more context now, I see that resolveSubPackage() is actually to be avoided, as it results in a full packages scan, killing the lazy-loading advantages. It's still used if the dub.selections.json contains a path-based selection, so with these current changes, we still get a full scan whenever depending on a subpackage of a path-selected parent package.
There was a problem hiding this comment.
Right, anything that calls getPackageIterator needs to go / be reworked.
9b6c23b to
32ade85
Compare
No description provided.