dub icon indicating copy to clipboard operation
dub copied to clipboard

dub run should create workingDirectory if it doesn't already exist

Open Protonull opened this issue 3 weeks ago • 0 comments

As per the documentation, workingDirectory is the directory cd'd into prior to running the executable from dub run. This is particularly useful if your program populates its local directory with default configs and other files, so you can simply define a folder as the workingDirectory, put that folder in .gitignore and have an easy way to run debug builds without cluttering your project.

The problem is that this folder is not auto-created by dub, resulting in the following awkward situations:

  • Everyone who clones your repo has to manually create the folder, probably after an unsuccessful dub run attempt.

  • Use preRunCommands to run some D code as a script to create the folder (since mkdir works differently on Windows and Linux and will exit with 1 if the folder already exists unless you set incompatible flags).

  • You use some kind of wrapping build system, eg: calling dub from Gradle and creating-if-needed the workingDirectory.

  • You create the folder and then a .gitkeep, cluttering your project.

All of this would be obviated if dub could simply make the folder itself.

Protonull avatar Dec 13 '25 08:12 Protonull