kovidgoyal/kitty · warning

No user record available for user with UID: %#v

Error message

No user record available for user with UID: %#v

What it means

LoginShellForUser resolves the shell for a *user.User by looking up the user's UID in the passwd database. This error means the user struct was obtained (e.g. from user.Current or user.LookupId) but no passwd record with that UID exists in the database this library consults, so no shell can be determined.

Source

Thrown at tools/utils/passwd.go:143

})

func LoginShellForUser(u *user.User) (ans string, err error) {
	var db map[string]PasswdEntry
	switch runtime.GOOS {
	case "darwin":
		db = dscl_user_database()
		err = dscl_error
	default:
		db = passwd_database()
		err = passwd_err
	}
	if err != nil {
		return
	}
	if rec, found := db[u.Uid]; found {
		return rec.Shell, nil
	}
	return ans, fmt.Errorf("No user record available for user with UID: %#v", u.Uid)
}

func CurrentUser() (ans *user.User, err error) {
	ans, err = user.Current()
	if err != nil && runtime.GOOS == "darwin" {
		uid := strconv.Itoa(os.Geteuid())
		db := dscl_user_database()
		if dscl_error != nil {
			err = dscl_error
			return
		}
		if rec, found := db[uid]; found {
			u := user.User{Uid: uid, Gid: rec.Gid, Username: rec.Username, Name: rec.Gecos, HomeDir: rec.Home}
			ans = &u
			err = nil
		} else {
			err = fmt.Errorf("Could not find the current uid: %d in the DSCL user database", os.Geteuid())
		}

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Confirm the user record: `getent passwd $UID` / `dscl . -read /Users/$USER`.
  2. Restart the directory service (macOS: `killall DirectoryService`/`dscl`) or refresh SSSD/nscd caches on Linux.
  3. In containers, add the user to /etc/passwd in the image.
  4. Fall back to a default shell such as /bin/sh when the lookup fails.

Example fix

// before
shell, err := utils.LoginShellForCurrentUser()
// after
shell, err := utils.LoginShellForCurrentUser()
if err != nil {
    shell = "/bin/sh"
}
Defensive patterns

Strategy: fallback

Validate before calling

if _, err := user.LookupId(strconv.Itoa(u.Uid)); err != nil {
    // record missing; expect LoginShellForUser to fail
}

Try / catch

shell, err := utils.LoginShellForUser(u)
if err != nil {
    shell = "/bin/sh"
    err = nil
}

Prevention

When it happens

Trigger: Calling LoginShellForUser/LoginShellForCurrentUser where the user's UID has no passwd entry: user deleted after login, LDAP/NIS user missing from the local cache, or a container user defined only in the orchestrator.

Common situations: macOS with directory-service lag, LDAP outages where getpwuid fails, or CI containers running as arbitrary UIDs. Typically hit when the tool tries to figure out which shell to spawn config for.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/97bee203ba84f631. Report an issue: GitHub.