In environments where username not in /etc/passwd codex errors out

Resolved 💬 2 comments Opened Jun 7, 2025 by dcieslak19973 Closed Aug 7, 2025

What version of Codex is running?

0.1.2505172129

Which model were you using?

Any

What platform is your computer?

Linux 5.14.0-503.21.1.el9_5.x86_64 x86_64 x86_64

What steps can reproduce the bug?

  1. Run on a machine where users are not in /etc/passwd (e.g. auth is handled by LDAP)
  2. Install node via Nix
  3. Run node -e 'console.log(require("os").userInfo())'

Nix-provided Node (and glibc) only consults NSS modules installed in the Nix store (not /lib64/libnss_sss.so.2), even if you use FHS mode. When using SSSD/LDAP, only the system Node (linked to host glibc and NSS modules) will work for LDAP/NSS user lookups. Python sometimes "escapes" this problem, but Node never will in this setup.

See also https://nodejs.org/docs/latest-v22.x/api/os.html#os_os_userinfo_options

What is the expected behavior?

codex not to fail in these environments

What do you see instead?

codex --help
SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_get_passwd returned ENOENT (no such file or directory)
    at Object.userInfo (node:os:359:11)
    at SOME_BASE_PATH/node_modules/@openai/codex/dist/cli.js:600:3739 {
  code: 'ERR_SYSTEM_ERROR',
  info: {
    errno: -2,
    code: 'ENOENT',
    message: 'no such file or directory',
    syscall: 'uv_os_get_passwd'
  },
  errno: [Getter/Setter: -2],
  syscall: [Getter/Setter: 'uv_os_get_passwd']
}

Additional information

Proposed solution:

Change agent-loop.ts line 1600 from:

const userName = os.userInfo().username;

To:

try {
  userName = os.userInfo().username;
} catch (error) {
  log("os.userInfo() failed, attempting to read username from environment variables:", error);
  userName = process.env["USER"] || "unknown_user";
  if (userName === "unknown_user") {
    log("Could not determine username from os.userInfo() or environment variable USER. Using default 'unknown_user'.");
  }
}

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗