authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-01-26 23:55:17-08:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-01-27 20:48:25+01:00
log29b7214027b0c9bddc4c67587ee75b4adcdab4f8
tree96db647c5d95cf56fbd3d599a071ada0141740b8
parent3729a53eec1951376c01c7e799b439b1a84694b5

Disentangle from `error.CurrentWorkingDirectoryUnlinked`

This error is actually only ever directly returned from `std.posix.getcwd` (and only on POSIX systems, so never on Windows). Its inclusion in almost all of the error sets its currently found in is a leftover from when `std.fs.path.resolve` called `std.process.getCwdAlloc` (https://github.com/ziglang/zig/issues/13613).

6 files changed, 5 insertions(+), 12 deletions(-)

lib/std/posix.zig+1
......@@ -521,6 +521,7 @@ pub fn getppid() pid_t {
521521
522522pub const GetCwdError = error{
523523 NameTooLong,
524 /// Not possible on Windows.
524525 CurrentWorkingDirectoryUnlinked,
525526} || UnexpectedError;
526527
lib/std/process.zig+4-3
......@@ -73,7 +73,10 @@ pub fn getCwd(out_buffer: []u8) GetCwdError![]u8 {
7373}
7474
7575// Same as GetCwdError, minus error.NameTooLong + Allocator.Error
76pub const GetCwdAllocError = Allocator.Error || error{CurrentWorkingDirectoryUnlinked} || posix.UnexpectedError;
76pub const GetCwdAllocError = Allocator.Error || error{
77 /// Not possible on Windows.
78 CurrentWorkingDirectoryUnlinked,
79} || posix.UnexpectedError;
7780
7881/// Caller must free the returned memory.
7982/// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/).
......@@ -342,8 +345,6 @@ pub const SpawnError = error{
342345 /// Windows-only. `cwd` or `argv` was provided and it was invalid WTF-8.
343346 /// https://wtf-8.codeberg.page/
344347 InvalidWtf8,
345 /// Windows-only. `cwd` was provided, but the path did not exist when spawning the child process.
346 CurrentWorkingDirectoryUnlinked,
347348 /// Windows-only. NUL (U+0000), LF (U+000A), CR (U+000D) are not allowed
348349 /// within arguments when executing a `.bat`/`.cmd` script.
349350 /// - NUL/LF signifiies end of arguments, so anything afterwards
lib/std/zig/system.zig-1
......@@ -504,7 +504,6 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
504504 if (builtin.os.tag == .linux and result.isBionicLibC() and query.os_tag == null and query.android_api_level == null) {
505505 result.os.version_range.linux.android = detectAndroidApiLevel(io) catch |err| return switch (err) {
506506 error.InvalidWtf8,
507 error.CurrentWorkingDirectoryUnlinked,
508507 error.InvalidBatchScriptArg,
509508 => unreachable, // Windows-only
510509 error.ApiLevelQueryFailed => |e| e,
src/Compilation.zig-3
......@@ -1851,7 +1851,6 @@ fn addModuleTableToCacheHash(
18511851) error{
18521852 OutOfMemory,
18531853 Unexpected,
1854 CurrentWorkingDirectoryUnlinked,
18551854}!void {
18561855 assert(zcu.module_roots.count() != 0); // module_roots is populated
18571856
......@@ -1919,7 +1918,6 @@ pub const CreateError = error{
19191918 OutOfMemory,
19201919 Canceled,
19211920 Unexpected,
1922 CurrentWorkingDirectoryUnlinked,
19231921 /// An error has been stored to `diag`.
19241922 CreateFail,
19251923};
......@@ -2906,7 +2904,6 @@ pub const UpdateError = error{
29062904 OutOfMemory,
29072905 Canceled,
29082906 Unexpected,
2909 CurrentWorkingDirectoryUnlinked,
29102907};
29112908
29122909/// Detect changes to source files, perform semantic analysis, and update the output files.
src/Sema.zig-4
......@@ -13604,10 +13604,6 @@ fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1360413604 error.ImportOutsideModulePath => {
1360513605 return sema.fail(block, operand_src, "embed of file outside package path: '{s}'", .{name});
1360613606 },
13607 error.CurrentWorkingDirectoryUnlinked => {
13608 // TODO: this should be some kind of retryable failure, in case the cwd is put back
13609 return sema.fail(block, operand_src, "unable to resolve '{s}': working directory has been unlinked", .{name});
13610 },
1361113607 error.OutOfMemory => |e| return e,
1361213608 error.Canceled => |e| return e,
1361313609 };
src/Zcu/PerThread.zig-1
......@@ -2388,7 +2388,6 @@ pub fn embedFile(
23882388 OutOfMemory,
23892389 Canceled,
23902390 ImportOutsideModulePath,
2391 CurrentWorkingDirectoryUnlinked,
23922391}!Zcu.EmbedFile.Index {
23932392 const zcu = pt.zcu;
23942393 const gpa = zcu.gpa;