dd86k's blog

Machine code enthusiast

Trick to Setting Up DMD on Windows when using DUB and rdmd

Author: dd
Published: January 7, 2023
Last modified: May 28, 2023 at 18h41
Categories:

Damn it, Margaret, rdmd+dmd32 permissions issues on the executable again!

The DigitalMars D compiler came a long, long way since its introduction since the early 2000s.

And so have Windows permissions and SysWoW64.

I sometimes use rdmd (or gdmd, ldmd2) to generate git tags in my projects, which works fine as-is outside of DUB.

However, for some reason, when I use the DMD compiler build on my Windows machine through using a rdmd build script in a DUB project, the build stops, indicating that elevated permissions are required to run the temporary build that DMD, through rdmd, generated.

dub spawning rdmd from bin64 but somehow fails with permission

Yet, if I change my PATH to point to the DMD64 build, well, such issues do not occur. Why is that? I don’t know, ✨ Kernel Thunk or OPTLINK magic ✨, maybe?

Anyway, here’s my tip of the day: If you point your PATH to both the DMD32 (bin) and DMD64 (bin64), rename the former from dmd.exe to dmd32.exe. Don’t worry, you can still specify the --compiler=dmd32 switch from DUB to select it.

Yay!

Do note that whichever bin64 or bin comes first do not matter, somehow. Maybe something regarding rdmd finding the compiler? Oh well, I have no idea why this happens, but hey, that is now fixed.

That’s all!

EDIT 2023-01-15: At least, starting with DMD 2.102.0-nightly, the Windows installer will now prefer the DMD64 compiler over DMD32, which may resolve this issue if you prefer the installer to add dmd in your PATH.