Thread overview
Want a module to import from a sister directork; How?
Feb 14, 2023
jwatson-CO-edu
Feb 14, 2023
ryuukk_
Feb 14, 2023
jwatson-CO-edu
Feb 14, 2023
ryuukk_
Feb 14, 2023
Adam D Ruppe
Feb 14, 2023
ryuukk_
February 14, 2023

I have the following directory structure:

ANN/
    ANN/mathkit/
        ANN/mathkit/package.d
    ANN/utils/
        ANN/utils/package.d
    ANN/MLP.d

I have the following in "ANN/mathkit/package.d":

module ANN.mathkit;
//...
/// Local Imports ///
import ANN.utils;
//...

I have the following in "ANN/MLP.d":

import mathkit;
//...
void main(){ /* ... */ }

When I
rdmd MLP.d

I get the following error:

mathkit/package.d(7): Error: unable to read module `utils`
mathkit/package.d(7):        Expected 'ANN/utils.d' or 'ANN/utils/package.d' in one of the following import paths: // ...

How do I build my project with these dependencies?:

utils --> mathkit --> MLP
    \                 ,^
     `---------------'

Must I choose a different structure?
Should I be using DUB?

February 14, 2023

I think you need to do:

rdmd MLP.d -I ANN/

Basically you need to tell the compiler where your imported packages are

February 14, 2023

On Tuesday, 14 February 2023 at 17:56:39 UTC, ryuukk_ wrote:

>

I think you need to do:

rdmd MLP.d -I ANN/

Basically you need to tell the compiler where your imported packages are

This did the trick. I did not need it when utils was the only local import, but I suppose the compiler needs a little more help when sibling packages depend on each other.

February 14, 2023

Glad it worked!

I wonder why DMD doesn't just parse the import and follow its path since module name must correspond to its path

Does anyone know?

February 14, 2023
On Tuesday, 14 February 2023 at 21:23:26 UTC, ryuukk_ wrote:
> module name must correspond to its path

this is not true.

February 14, 2023
On Tuesday, 14 February 2023 at 21:55:24 UTC, Adam D Ruppe wrote:
> On Tuesday, 14 February 2023 at 21:23:26 UTC, ryuukk_ wrote:
>> module name must correspond to its path
>
> this is not true.

I thought it had to match, that's interesting