From d06c9c7aae045d29c949e7e38bc3f9eac4bfec23 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 24 Sep 2025 12:51:09 -0700 Subject: [PATCH] fix: file creation when directory already exists (#8892) Resolves #8890 If you try to create the config file when the directory already exists, you (I) get an error that the _file_ path already exists. ``` warning(config): error creating template config file err=error.PathAlreadyExists ``` Even though the file does not exist. By changing the API entry point, this error goes away. I have no solid explanation for why this change works. | State | Old Behavior | New Behavior | |--------|--------|--------| | A config file exists | N/A | N/A | | No config file, no directory | create directory and config file | N/A | | No config file, yes directory | fail to create on config file | create config file | This behavior is confirmed on my macOS 26 machine. It is the least intrusive change I could make, and in all other situations should be a no-op. --- src/config/Config.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/Config.zig b/src/config/Config.zig index 932576558..33c5c737f 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -3357,7 +3357,7 @@ pub fn loadOptionalFile( fn writeConfigTemplate(path: []const u8) !void { log.info("creating template config file: path={s}", .{path}); if (std.fs.path.dirname(path)) |dir_path| { - try std.fs.makeDirAbsolute(dir_path); + try std.fs.cwd().makePath(dir_path); } const file = try std.fs.createFileAbsolute(path, .{}); defer file.close();