// test.d enum x = __traits(compiles, (){ import doesNotExist; }); DMD works: > dmd -c test.d RDMD fails: > rdmd -c test.d Error: cannot read file doesNotExist.d The problem is RDMD gets dependencies by reading DMD's -v output, which always includes doesNotExist (since DMD *does* attempt to import it). Since RDMD sees doesNotExist in the -v output, it mistakenly tries to build it. This prevents optional imports from working with RDMD: static if( __traits(compiles, (){ import foobar; }) ) { import foobar; } else /+ do something else +/ It might be better for RDMD to read the -deps output instead, and omit the files listed with "(???)" as the filename.
RDMD still uses -v but DMD -v doesn't include it anymore so it works now