When using dub as a library, I encountered a strange phenomenon that can only be reproduced in a windows-x86-dmd environment.
Following is a batch process that reproduces this phenomenon:
------
PATH=C:\D\dmd-2.090.0\windows\bin;%PATH%
dub init . dub -t minimal -f json -n -q
echo import std.stdio, dub.dub; > source\app.d
echo unittest { >> source\app.d
echo auto dub = new Dub("."); >> source\app.d
echo dub.loadPackage(); >> source\app.d
echo writeln(dub.project.rootPackage.version_.toString()); >> source\app.d
echo } >> source\app.d
echo void main() {} >> source\app.d
dub test -a=x86 --coverage -f
------
According to my research, the static immutable variable `dub.dependency.Version.masterBranch`, which is referred to when determining the root package version when during `dub.loadPackage()`, is broken for some reason. (Curiously the string "dub.json" is referenced)
--- dub.package_ ---
106: // TODO: Assume unknown version here?
107: // recipe.version_ = Version.unknown.toString();
108: recipe.version_ = Version.masterBranch.toString();
--------------------
Following are some other reproduction conditions I have found:
- The same happens at least at 2.086.1 (I haven't looked elsewhere, but it seems to be a potential problem)
- It is NOT reproduced when building without `--coverage`.
- It is NOT reproduced when building with `--build-mode=singleFile`.
- The address of dub.dependency.Version.masterBranch is different when it is referenced between `dub.package_` and `source/app.d`
Comment #1 by robert.schadek — 2024-12-13T19:06:57Z