问题
Here is the project structure:
.
├── dub.json
├── dub.selections.json
├── dub.userprefs
├── source
│ └── app.d
└── testd2
Content of app.d
import std.stdio;
import scid.matrix;
import colorize: fg, color, cwriteln, cwritefln;
void main()
{
cwriteln("This is blue.".color(fg.blue));
auto c = "red";
cwritefln("This is %s".color(c), c);
}
Content of dub.josn:
{
"name": "testd2",
"description": "A minimal D application.",
"copyright": "Copyright © 2014, kaiyin",
"authors": ["kaiyin"],
"dependencies": {
"colorize": ">=1.0.5"
}
}
Build error:
dub build
Building colorize 1.0.5 configuration "library", build type debug.
Running dmd...
Building testd2 ~master configuration "application", build type debug.
Compiling using dmd...
source/app.d(2): Error: module matrix is in file 'scid/matrix.d' which cannot be read
import path[0] = source/
import path[1] = ../../../.dub/packages/colorize-1.0.5/source
import path[2] = /usr/local/Cellar/dmd/2.066.0/include/d2
FAIL .dub/build/application-debug-posix.osx-x86_64-dmd_2066-1DB186F012CD3E69677DBEA746FFBDE1/ testd2 executable
Error executing command build: dmd failed with exit code 1.
Any ideas about what went wrong? Thanks.
回答1:
Ok, my fault, I forgot to specify the dependency in dub.json
, it should be:
{
"name": "testd2",
"description": "A minimal D application.",
"copyright": "Copyright © 2014, kaiyin",
"authors": ["kaiyin"],
"dependencies": {
"colorize": ">=1.0.5",
"scid": ">=0.1.0"
}
}
Next time I see this kind of error, I will remeber to look there.
来源:https://stackoverflow.com/questions/27573909/module-x-is-in-x-d-which-cannot-be-read-error-when-compiling-a-d-program