netbirdio/netbird · error
get current user: %v
Error message
get current user: %v
What it means
Thrown by upFunc (client/cmd/up.go:127) when os/user.Current() fails. The username is needed to attribute profiles ('netbird up' stores who created a profile). In a cgo-disabled build Go parses /etc/passwd directly, so the lookup fails when the current UID has no passwd entry; with cgo it can also fail on NSS errors. The command aborts before profile handling.
Source
Thrown at client/cmd/up.go:127
}
dnsLabelsValidated, err = validateDnsLabels(dnsLabels)
if err != nil {
return err
}
ctx := internal.CtxInitState(cmd.Context())
if hostName != "" {
// nolint
ctx = context.WithValue(ctx, system.DeviceNameCtxKey, hostName)
}
pm := profilemanager.NewProfileManager()
username, err := user.Current()
if err != nil {
return fmt.Errorf("get current user: %v", err)
}
var profileSwitched bool
// switch profile if provided
if profileName != "" {
if err := switchOrCreateProfile(cmd.Context(), pm, profileName, username.Username); err != nil {
return fmt.Errorf("switch profile: %v", err)
}
profileSwitched = true
}
activeProf, err := pm.GetActiveProfile()
if err != nil {
return fmt.Errorf("get active profile: %v", err)
}
if foregroundMode {
return runInForegroundMode(ctx, cmd, activeProf)View on GitHub (pinned to 93e97f4bf1)
Solutions
- Run the container with a UID that exists in its /etc/passwd, or add an entry for the UID (useradd / nss_wrapper passwd file)
- Use an image that ships /etc/passwd (not scratch) or bind-mount one containing the runtime UID
- On hosts, verify 'id' works in the same shell/context before running netbird
Example fix
// before
username, err := user.Current()
if err != nil {
return fmt.Errorf("get current user: %v", err)
}
// after: fall back to an env-derived name for profile attribution
username, err := user.Current()
if err != nil {
fallback := os.Getenv("USER")
if fallback == "" {
return fmt.Errorf("get current user: %w", err)
}
log.Warnf("user.Current failed (%v), using $USER for profile attribution", err)
username = &user.User{Username: fallback}
} Defensive patterns
Strategy: fallback
Validate before calling
if _, err := user.Current(); err != nil {
log.Warnf("no passwd entry for uid %d - add one or set USER", os.Getuid())
} Prevention
- Run containers with a UID that exists in /etc/passwd or ship a passwd entry
- Prefer images that include /etc/passwd over scratch for netbird workloads
- Verify 'id' resolves in the same context before running netbird up
When it happens
Trigger: Running 'netbird up' in a container as a numeric UID absent from /etc/passwd (docker/podman --user 1000123:1000123, scratch images, K8s runAsNode-like arbitrary UIDs); /etc/passwd unreadable or malformed; NSS misconfiguration on the host.
Common situations: CI runners and distroless/scratch containers with random UIDs; hardening policies (OpenShift-assigned UIDs); chroot environments without a passwd file.
Related errors
- wait for extend session: %v
- switch profile: %v
- active profile not found, please run 'netbird profile create
- switch profile on daemon: %v
- switch profile failed: %w
AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16).
Data as JSON: /api/errors/a2a3cf98121824d9.
Report an issue: GitHub.