Module import failing after $ dub add mypackage

Scotpip geoff at variosoft.co.uk
Fri Jul 16 16:44:31 UTC 2021


On Friday, 16 July 2021 at 15:42:32 UTC, rikki cattermole wrote:

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

Thanks - that was helpful.

For anyone else with this issue I've figured out what went wrong.

I had more than one main() function in the project - I was using 
the others as sandboxes to play with code.

I was building with ```dub .\source\myfile.d```.

But you need to run dub without a filepath to build the whole 
project, including any 3rd party packages.

No doubt this is blindingly obvious to people used to working 
with compilers, but it would be helpful to newbies if this was a 
bit more explicit in the dub docs.

Again, if this helps anyone my current setup is to have a single 
main() in app.d. I changed the main() in my sandboxes to 
runSandbox(), and I import and run from app.d rather than 
directly. Or with a couple of keystrokes I can switch to running 
the full app. This seems to be a practical workflow that plays 
properly with the build system.

If anyone has a better suggestion, I'd appreciate your tips.


More information about the Digitalmars-d-learn mailing list