juicedata/juicefs · error
current user: %s
Error message
current user: %s
What it means
When newNFSStore is called with an empty username, it falls back to the current OS user via user.Current(). If that lookup fails (the process cannot determine its uid/username), the error is wrapped as 'current user: ...'.
Source
Thrown at pkg/object/nfs.go:462
func (n *nfsStore) findOwnerGroup(attr *nfs.Fattr) (string, string) {
return utils.UserName(int(attr.UID)), utils.GroupName(int(attr.GID))
}
func (n *nfsStore) getOwnerGroup(info os.FileInfo) (string, string) {
if st, match := info.(*nfs.Fattr); match {
return n.findOwnerGroup(st)
}
if st, match := info.Sys().(*nfs.Fattr); match {
return n.findOwnerGroup(st)
}
return "", ""
}
func newNFSStore(addr, username, pass, token string) (ObjectStorage, error) {
if username == "" {
u, err := user.Current()
if err != nil {
return nil, fmt.Errorf("current user: %s", err)
}
username = u.Username
}
b := strings.Split(addr, ":")
if len(b) != 2 {
return nil, fmt.Errorf("invalid NFS address %s", addr)
}
host := b[0]
path := b[1]
mount, err := nfs.DialMount(host, time.Second*3)
if err != nil {
return nil, fmt.Errorf("unable to dial MOUNT service %s: %v", addr, err)
}
auth := rpc.NewAuthUnix(username, uint32(utils.GetCurrentUID()), uint32(utils.GetCurrentGID()))
target, err := mount.Mount(path, auth.Auth())
target.Config.DirCount = 1 << 17
// Readdir returns up to 1M at a time, even if MaxCount is set larger
target.Config.MaxCount = 1 << 20View on GitHub (pinned to c9a67b23e8)
Solutions
- Pass an explicit username in the NFS URL (user@host:/path) so the current-user lookup is skipped.
- Ensure /etc/passwd exists and contains the current uid, or rebuild with cgo enabled for NSS lookups.
- Run in an environment where getuid/getpwuid resolve (non-sandboxed container with a passwd file).
Example fix
// before
newNFSStore("nfs-server:/export/data", "", "", "")
// after
newNFSStore("nfs-server:/export/data", "myuser", "", "") Defensive patterns
Strategy: fallback
Validate before calling
if username == "" {
if _, err := user.Current(); err != nil {
return fmt.Errorf("cannot determine current user; pass an explicit username: %w", err)
}
} Try / catch
store, err := newNFSStore(addr, username, pass, "")
if err != nil && strings.Contains(err.Error(), "current user") {
// retry with an explicit username
store, err = newNFSStore(addr, "nobody", pass, "")
} Prevention
- Always supply an explicit username for NFS storage URLs.
- Avoid CGO_ENABLED=0 static builds when NSS user lookup is required.
- Ensure /etc/passwd is present in minimal container images.
When it happens
Trigger: Creating an NFS object store without a username while user.Current() fails — typically in static binaries built without cgo where user lookup needs NSS, or in restricted sandboxes.
Common situations: CGO_ENABLED=0 static builds where os/user can't consult NSS; minimal containers lacking /etc/passwd; environments where getpwuid fails.
Understand the failure class
Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.
Related errors
- user(%s):group(%s) not found
- user(%s):group(%s) not found
- get current user: %s
- invalid NFS address %s
- unable to dial MOUNT service %s: %v
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/f5b832e943d576c5.
Report an issue: GitHub.