DUB "Error: only one `main` allowed."

Mike Parker aldacron at gmail.com
Wed Aug 11 10:21:05 UTC 2021


On Wednesday, 11 August 2021 at 09:38:13 UTC, tastyminerals wrote:

>
> Hahaha, I fixed it by renaming the `my_script.d` to `app.d`. Oh 
> boy.

What you want is the `mainSourceFile` entry. From the dub 
documentation, [under "Build Settings"][1]:

> Determines the file that contains the main() function. This 
> setting can be used by dub to exclude this file in situations 
> where a different main function is defined (e.g. for "dub 
> test") - this setting does not support platform suffixes

`app.d` has special significance to dub in that it automatically 
triggers the executable target type if it's present. I assume dub 
also considers it the main source file by default if you have one.

[1]: https://dub.pm/package-format-json.html#build-settings


More information about the Digitalmars-d-learn mailing list