Skip to content

std.process.getUserInfo not work for macOS #23658

@dacheng-gao

Description

@dacheng-gao

Zig Version

0.14.0

Steps to Reproduce and Observed Behavior

example code:

const std = @import("std");
const process = std.process;

// macOS: user not found but it does
pub fn main() !void {
    const userInfo = try process.getUserInfo("gdc");
    std.debug.print("uid: {}\ngid: {}\n", .{userInfo.uid, userInfo.gid});
}

And zig run on macOS.

What I got:

[gdc@worldteam process] $ zig run getUserInfo.zig 
error: UserNotFound
/opt/homebrew/Cellar/zig/0.14.0_2/lib/zig/std/process.zig:1647:33: 0x1048ab2db in posixGetUserInfo (getUserInfo)
        if (amt_read < buf.len) return error.UserNotFound;
                                ^
/opt/homebrew/Cellar/zig/0.14.0_2/lib/zig/std/process.zig:1529:5: 0x1048ab4d3 in getUserInfo (getUserInfo)
    return switch (native_os) {
    ^
/Users/gdc/Repos/dacheng-zig/hello-zig/process/getUserInfo.zig:6:22: 0x1048ab567 in main (getUserInfo)
    const userInfo = try process.getUserInfo("gdc");

Expected Behavior

return UserInfo struct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-macosstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions