Comment #0 by CrypticMetaphor88 — 2010-12-19T18:47:59Z
Overview:
Calling rdmd from outside the folder in which the main source file resides in, and the main source file imports another file, causes an error.
Steps to reproduce:
Steps to reproduce & Actual results::
example:
...\projectfolder\src\main.d
...\projectfolder\src\test.d
// main.d
module main;
import test.d;
void main()
{
hello();
}
// end main.d
// test.d
module test.d;
import std.stdio;
void hello()
{
writeln("Hello");
}
// end test.d
// If I'm in a shell, and I do this, I get an error:
...\projectfolder>rdmd src\main.d
src\main.d(2): Error: module test is in file 'test.d' which cannot be read
import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import
// If I call this, I generate a main.d.deps file that can't find main.d
// last line of main.d.deps: "Error: cannot read file main.d"
...\projectfolder>rdmd -I(absolute path to src) main.d
// but if I do this, it works:
...\projectfolder\src>rdmd main.d
...\projectfolder\src>Hello world
// also works with
...\projectfolder\src>dmd main.d test.d // compiles
Expected results:
The application should work because the location of the main and the other files file is known when the program is ran. Or, at least, you should be able to specify a directory as an argument to rdmd in which rdmd will work.
Build Date & Platform:
* rdmd build 20101220
* dmd 2.050
* Windows XP Pro
Additional Information:
I've found a workaround. I start a batch file to which I pass as argument the absolute path to the src directory. I go to that directory in the batch file, and execute rdmd.
Example batch file:
cd %1\src
build.bat
rdmd --build-only --chatty -of%1..\bin\main -I%1..\inc main.d
Comment #1 by CrypticMetaphor88 — 2010-12-19T18:50:16Z
> cd %1\src
> build.bat
> rdmd --build-only --chatty -of%1..\bin\main -I%1..\inc main.d
I meant
cd %1\src
rdmd --build-only --chatty -of%1..\bin\main -I%1..\inc main.d
Comment #2 by CrypticMetaphor88 — 2010-12-19T19:10:34Z
(In reply to comment #1)
> > cd %1\src
> > build.bat
> > rdmd --build-only --chatty -of%1..\bin\main -I%1..\inc main.d
>
> I meant
>
> cd %1\src
> rdmd --build-only --chatty -of%1..\bin\main -I%1..\inc main.d
what I really meant:
cd %1\src
rdmd --build-only --chatty -of%1bin\main -I%1inc main.d
Comment #3 by bus_dbugzilla — 2010-12-27T22:45:48Z
I'm pretty sure this is a duplicate of issue 4672
Comment #4 by andrei — 2013-02-26T08:06:06Z
According to my tests this is fixed, please reopen if you find other cases that need addressing.