hashicorp/nomad · error
failed to get current user: %w
Error message
failed to get current user: %w
What it means
raw_exec's Validate (unlike exec driver) runs tasks as the current client user unless a user override is given. When no override is set, it calls users.Current(); if that OS lookup fails, Validate returns 'failed to get current user', aborting task validation before start.
Source
Thrown at drivers/rawexec/driver_unix.go:23
package rawexec
import (
"fmt"
"github.com/hashicorp/nomad/helper/users"
"github.com/hashicorp/nomad/plugins/drivers"
)
func (d *Driver) Validate(cfg drivers.TaskConfig) error {
usernameToLookup := cfg.User
// Uses the current user of the client agent process
// if no override is given (differs from exec)
if usernameToLookup == "" {
user, err := users.Current()
if err != nil {
return fmt.Errorf("failed to get current user: %w", err)
}
usernameToLookup = user.Username
}
return d.userIDValidator.HasValidIDs(usernameToLookup)
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Ensure the UID the Nomad client runs as has a valid entry in the user database (/etc/passwd) or equivalent
- Explicitly set the task's 'user' in the job so the current-user lookup path is skipped
- Fix NSS configuration (nsswitch.conf, sssd) so user lookups resolve
- Run the Nomad client as a well-known system account
Example fix
// job spec before user = "" // after user = "nomad-task"
Defensive patterns
Strategy: validation
Validate before calling
u, err := users.Current()
if err != nil {
// fix user database/NSS before starting tasks with empty user override
}
if taskUser == "" { taskUser = u.Username } Try / catch
if err := driver.Validate(taskCfg); err != nil {
if strings.Contains(err.Error(), "failed to get current user") {
// check /etc/passwd entry for the client UID or set explicit task user
}
} Prevention
- Set an explicit 'user' in task config on hardened/containerized clients
- Verify the Nomad client UID resolves in the user database
- Keep NSS configuration (nsswitch.conf) functional on the host
When it happens
Trigger: StartTask/Validate with an empty task user override on a system where the current-UID lookup fails — e.g. no passwd entry for the running UID, restricted NSS, or a container/client environment without proper user database access.
Common situations: Nomad client running as a UID missing from /etc/passwd (containerized clients); broken nsswitch/sssd in hardened environments; Windows lookup failures for service accounts.
Related errors
- failed driver config validation: %v
- missing secret ID
- namespace cannot contain template delimiters or parenthesis
- wait config is nil or empty
- CSI.ControllerAttachVolume: VolumeID is required
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/bfa96de97088f79b.
Report an issue: GitHub.