`realpathAlloc` returns `error: Unexpected` when running Windows executable with Wine

I’m trying to cross-compile a binary from Linux to Windows, and I’m using Wine to test it. Here’s the code that causes the error:

pub fn main() !void {
    std.debug.print("{s}\n", .{try std.fs.cwd().realpathAlloc(std.heap.page_allocator, "path/here")});
}

Error:

error: Unexpected
Unable to dump stack trace: Unexpected

Running the Linux binary is fine, but when trying to run the Windows binary with Wine I get that error.

I can confirm this (Zig version 0.15.2, Wine 11.3).

realpath has several problems, see remove realpath() from the standard library · Issue #19353 · ziglang/zig · GitHub, it’s best to try and avoid it (even if that’s not always easy).

2 Likes