Module import failing after $ dub add mypackage

rikki cattermole rikki at cattermole.co.nz
Fri Jul 16 15:42:32 UTC 2021


On 17/07/2021 3:31 AM, Scotpip wrote:
> In dub.sdl I see: ```dependency "msgpack-d" version="~>1.0.3"```
> 
> In dub.selections.json I see:
> 
> ```
> {
>      "fileVersion": 1,
>      "versions": {
>          "msgpack-d": "1.0.3"
>      }
> }
> ```


Okay, its been added to your dub project. So far so good.

> When I try to import the msgpack  into my app.d main file, I get the error:
> 
> ```
> $ Error: module `msgpack` is in file 'msgpack.d' which cannot be read
>    import path[0] = C:\D\dmd2\windows\bin64\..\..\src\phobos
>    import path[1] = C:\D\dmd2\windows\bin64\..\..\src\druntime\import
> ```

This should be in source/app.d

> I get similar errors whether I build with dub, dmd or rdmd.

dmd and rdmd do not understand dub packages or anything else. They are 
the compiler. Only use dub and if you want to change compiler you tell 
dub this.

> The file msgpack.d which the build is searching for doesn't appear to be 
> on my system.

msgpack-d doesn't have a file named msgpack.d. It does have a package.d 
file inside its msgpack directory which functions as this.

You should find it under %APPDATA%/dub

``$ dub build`` inside of ``myproject`` should work.


More information about the Digitalmars-d-learn mailing list