cockroachdb/cockroach · error

user.Current: %s

Error message

user.Current: %s

What it means

roachtest's getUser falls back to os/user.Current() when no --user flag is given, and panics if that call fails. user.Current fails when the process runs under a UID with no /etc/passwd entry (or passwd/nss resolution is unavailable) — the classic container/CI scenario. The panic aborts the roachtest invocation before any test runs.

Source

Thrown at pkg/cmd/roachtest/run.go:284

	if spec.Skip == "" {
		return ""
	}
	details := spec.Skip
	if spec.SkipDetails != "" {
		details += " (" + spec.SkipDetails + ")"
	}
	return details
}

// getUser takes the value passed on the command line and comes up with the
// username to use.
func getUser(userFlag string) string {
	if userFlag != "" {
		return userFlag
	}
	usr, err := user.Current()
	if err != nil {
		panic(fmt.Sprintf("user.Current: %s", err))
	}
	return usr.Username
}

func initRunFlagsBinariesAndLibraries(cmd *cobra.Command) error {
	if roachtestflags.Local {
		if roachtestflags.ClusterNames != "" {
			return fmt.Errorf(
				"cannot specify both an existing cluster (%s) and --local. However, if a local cluster "+
					"already exists, --clusters=local will use it",
				roachtestflags.ClusterNames)
		}
		roachtestflags.Cloud = spec.Local
	}

	if roachtestflags.Count <= 0 {
		return fmt.Errorf("--count (%d) must by greater than 0", roachtestflags.Count)
	}

View on GitHub (pinned to 8812064a01)

Solutions

  1. Pass --user explicitly: ./roachtest run --user=$USER <test> (any stable string works)
  2. Fix the image: add the uid to /etc/passwd (useradd -u $(id -u) runner) or use a base image that includes passwd
  3. In k8s, set runAsUser to an existing uid or project a generated /etc/passwd file into the pod

Example fix

# before
./roachtest run my_test

# after
./roachtest run --user=ci-runner my_test
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Running roachtest without --user under a numeric UID that has no passwd entry: scratch/distroless containers, Kubernetes pods with arbitrary runAsUser, CI runners with dynamic UIDs, or images missing /etc/passwd.

Common situations: CI moving roachtest into a minimal container; k8s jobs assigning project-range UIDs; chroot/nsswitch misconfiguration on build agents.

Related errors


AI-assisted analysis of cockroachdb/cockroach@8812064a01 (2026-08-15). Data as JSON: /api/errors/bcf3b6d03d6abd02. Report an issue: GitHub.