zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 29b7214027b0c9bddc4c67587ee75b4adcdab4f8 (tree)
parent 3729a53eec1951376c01c7e799b439b1a84694b5
Author: Ryan Liptak <squeek502@hotmail.com>
Date:   Mon, 26 Jan 2026 23:55:17 -0800

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).

Diffstat:
Mlib/std/posix.zig | 1+
Mlib/std/process.zig | 7++++---
Mlib/std/zig/system.zig | 1-
Msrc/Compilation.zig | 3---
Msrc/Sema.zig | 4----
Msrc/Zcu/PerThread.zig | 1-
6 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/lib/std/posix.zig b/lib/std/posix.zig @@ -521,6 +521,7 @@ pub fn getppid() pid_t { pub const GetCwdError = error{ NameTooLong, + /// Not possible on Windows. CurrentWorkingDirectoryUnlinked, } || UnexpectedError; diff --git a/lib/std/process.zig b/lib/std/process.zig @@ -73,7 +73,10 @@ pub fn getCwd(out_buffer: []u8) GetCwdError![]u8 { } // Same as GetCwdError, minus error.NameTooLong + Allocator.Error -pub const GetCwdAllocError = Allocator.Error || error{CurrentWorkingDirectoryUnlinked} || posix.UnexpectedError; +pub const GetCwdAllocError = Allocator.Error || error{ + /// Not possible on Windows. + CurrentWorkingDirectoryUnlinked, +} || posix.UnexpectedError; /// Caller must free the returned memory. /// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/). @@ -342,8 +345,6 @@ pub const SpawnError = error{ /// Windows-only. `cwd` or `argv` was provided and it was invalid WTF-8. /// https://wtf-8.codeberg.page/ InvalidWtf8, - /// Windows-only. `cwd` was provided, but the path did not exist when spawning the child process. - CurrentWorkingDirectoryUnlinked, /// Windows-only. NUL (U+0000), LF (U+000A), CR (U+000D) are not allowed /// within arguments when executing a `.bat`/`.cmd` script. /// - NUL/LF signifiies end of arguments, so anything afterwards diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig @@ -504,7 +504,6 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target { if (builtin.os.tag == .linux and result.isBionicLibC() and query.os_tag == null and query.android_api_level == null) { result.os.version_range.linux.android = detectAndroidApiLevel(io) catch |err| return switch (err) { error.InvalidWtf8, - error.CurrentWorkingDirectoryUnlinked, error.InvalidBatchScriptArg, => unreachable, // Windows-only error.ApiLevelQueryFailed => |e| e, diff --git a/src/Compilation.zig b/src/Compilation.zig @@ -1851,7 +1851,6 @@ fn addModuleTableToCacheHash( ) error{ OutOfMemory, Unexpected, - CurrentWorkingDirectoryUnlinked, }!void { assert(zcu.module_roots.count() != 0); // module_roots is populated @@ -1919,7 +1918,6 @@ pub const CreateError = error{ OutOfMemory, Canceled, Unexpected, - CurrentWorkingDirectoryUnlinked, /// An error has been stored to `diag`. CreateFail, }; @@ -2906,7 +2904,6 @@ pub const UpdateError = error{ OutOfMemory, Canceled, Unexpected, - CurrentWorkingDirectoryUnlinked, }; /// Detect changes to source files, perform semantic analysis, and update the output files. diff --git a/src/Sema.zig b/src/Sema.zig @@ -13604,10 +13604,6 @@ fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A error.ImportOutsideModulePath => { return sema.fail(block, operand_src, "embed of file outside package path: '{s}'", .{name}); }, - error.CurrentWorkingDirectoryUnlinked => { - // TODO: this should be some kind of retryable failure, in case the cwd is put back - return sema.fail(block, operand_src, "unable to resolve '{s}': working directory has been unlinked", .{name}); - }, error.OutOfMemory => |e| return e, error.Canceled => |e| return e, }; diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig @@ -2388,7 +2388,6 @@ pub fn embedFile( OutOfMemory, Canceled, ImportOutsideModulePath, - CurrentWorkingDirectoryUnlinked, }!Zcu.EmbedFile.Index { const zcu = pt.zcu; const gpa = zcu.gpa;