Skip to content

Commit 4b75aea

Browse files
authored
fix: auto-create workingDirectory before running executable (#3097)
Create the workingDirectory if it does not exist before spawning the target process. This prevents `dub run` from failing when the workingDirectory has not been created yet. Fixes #3082
1 parent 3be7c51 commit 4b75aea

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

source/dub/generators/build.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ class BuildGenerator : ProjectGenerator {
692692
runcwd = NativePath(buildsettings.workingDirectory);
693693
if (!runcwd.absolute) runcwd = cwd ~ runcwd;
694694
}
695+
ensureDirectory(runcwd);
695696
if (!exe_file_path.absolute) exe_file_path = cwd ~ exe_file_path;
696697
runPreRunCommands(m_project.rootPackage, m_project, settings, buildsettings);
697698
logInfo("Running", Color.green, "%s %s", exe_file_path.relativeTo(runcwd), run_args.join(" "));
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "issue3082-workingdir-autocreate",
3+
"workingDirectory": "bin"
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import std.stdio;
2+
import std.path;
3+
import std.file;
4+
5+
void main()
6+
{
7+
assert(baseName(getcwd()) == "bin");
8+
writeln("ok");
9+
}

0 commit comments

Comments
 (0)