"模块x在x.d中,无法读取"编译d程序时出错

时间:2014-12-19 21:08:49

标签: d

这是项目结构:

.
├── dub.json
├── dub.selections.json
├── dub.userprefs
├── source
│   └── app.d
└── testd2

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);
}

dub.josn的内容:

{
    "name": "testd2",
    "description": "A minimal D application.",
    "copyright": "Copyright © 2014, kaiyin",
    "authors": ["kaiyin"],
    "dependencies": {
        "colorize": ">=1.0.5"
    }
}

构建错误:

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.

关于出了什么问题的任何想法?感谢。

1 个答案:

答案 0 :(得分:1)

好的,我的错,我忘了在dub.json中指定依赖项,它应该是:

{
    "name": "testd2",
    "description": "A minimal D application.",
    "copyright": "Copyright © 2014, kaiyin",
    "authors": ["kaiyin"],
    "dependencies": {
        "colorize": ">=1.0.5",
        "scid": ">=0.1.0"
    }
}

下次我看到这种错误时,我会记得去看那里。