Closed AndrejMitrovic closed 1 year ago
This suddenly made LDC the default compiler.
Actually the bug is a little more subtle. The gist of the logic is here: https://github.com/dlang/dub/blob/efefe1420a480d6800146d6aea5136331e0525fb/source/dub/dub.d#L1406-L1424
What happened is that, after uninstalling dmd, you started to use a different dub. The LDC-packaged dub
, instead of the dmd-packaged one. And since dub prefers the compiler adjacent to itself, it used LDC.
In this case, it sounds like the installer shouldn't change the env if it's going to replace DMD (if the paths are the same). You could also add "defaultCompiler": "dmd"
in %ProgramData%/dub/settings.json
(system settings) or %APPDATA%/dub/settings.json
(user settings) to make sure dmd from PATH is always used, regardless of where dub is.
Ah damn I think you are right. Thanks for the tips. Can close this.
https://github.com/dlang/dub/blob/efefe1420a480d6800146d6aea5136331e0525fb/source/dub/dub.d#L404-L413
The way I'm reading this makes me think it will try to find dmd first, in whichever path, then gdc, then gdmd, etc. Perhaps it can be worded a little better.
What dub is actually doing is walking through each PATH entry, and then checking if it can find any of dmd, gdc, gdmd, etc in each of those paths. So the order of items in the PATH matters (I can replicate it's doing this).
If that ddoc comment is updated maybe the note should also be added to https://dub.pm/settings on how dub finds a default compiler if it's not set up in any settings file.
I've ran into https://issues.dlang.org/show_bug.cgi?id=23642 while reinstalling DMD on Windows. The installer removed the existing PATH entry (DMD was first), and then added it again at the end. This suddenly made LDC the default compiler. Anyway that's an installer bug / enhancement, nothing to do with dub. :)