jdx/mise · error

cannot determine the current user to own

Error message

cannot determine the current user to own {prefix}

What it means

bootstrap creates and chowns the brew prefix to the current user (or SUDO_USER under sudo mise). It deliberately refuses to guess an owner: prefix_owner() returns None when there is no invoking sudo user and the effective uid cannot be resolved to a username (e.g. plain root in a container without a passwd entry, or a deleted user). Chowning to a guessed owner could lock the real user out, so mise errors instead.

Solutions

  1. Run mise as a normal user instead of root, or ensure SUDO_USER is correct when using sudo
  2. Fix the container's /etc/passwd so the current uid maps to a username (e.g. ensure root:x:0:0:root:/root:/bin/sh exists)
  3. Pre-create the prefix yourself with correct ownership (mkdir + chown to your user) so bootstrap finds it writable and skips the chown path

Example fix

# before (docker)
USER root
RUN mise bootstrap packages apply
# after
RUN mkdir -p /home/linuxbrew/.linuxbrew && chown -R developer /home/linuxbrew
USER developer
Defensive patterns

Strategy: validation

Validate before calling

u="${SUDO_USER:-$(id -un)}"
id "$u" >/dev/null 2>&1 || echo "owner user '$u' does not resolve — fix /etc/passwd or SUDO_USER"

Prevention

When it happens

Trigger: bootstrap needs to create the prefix or chown it (needs_create || needs_chown) but prefix_owner() returns None — running as plain root with no SUDO_USER and no passwd entry for uid 0's name lookup, or SUDO_USER names a nonexistent user.

Common situations: `sudo mise ...` where SUDO_USER is set to a user deleted from /etc/passwd; docker run as root in minimal images with an empty/broken /etc/passwd; nixpkgs/static-linking edge cases where nix::unistd::User::from_uid fails.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/a88c5aad89849ab5. Report an issue: GitHub.

Appendix: source

Thrown at src/system/packages/brew/prefix.rs:204

    let missing_subdirs: Vec<PathBuf> = dirs.iter().filter(|p| !p.exists()).cloned().collect();
    if !needs_create && !needs_chown && missing_subdirs.is_empty() {
        return Ok(());
    }
    // try without elevation first — covers prefixes under user-writable
    // parents; the real prefixes need sudo to create. Skipped under `sudo
    // mise`: root could create the dirs, but they must be chowned to the
    // invoking user afterwards
    if needs_create
        && !dry_run
        && sudo_invoking_user().is_none()
        && dirs.iter().try_for_each(std::fs::create_dir_all).is_ok()
    {
        return Ok(());
    }
    if needs_create || needs_chown {
        let Some(user) = prefix_owner() else {
            // never chown to a guessed owner — that can lock the user out
            bail!(
                "cannot determine the current user to own {}",
                prefix.display()
            );
        };
        // brew's install.sh chowns to user:admin on macOS, just the user on
        // Linux (the admin group doesn't exist there)
        let owner = if cfg!(target_os = "macos") {
            format!("{user}:admin")
        } else {
            user
        };
        let mut mkdir_dirs: Vec<String> = vec![prefix.to_string_lossy().to_string()];
        mkdir_dirs.extend(dirs.iter().map(|d| d.display().to_string()));
        let mkdir_args: Vec<String> = ["-p".to_string()].into_iter().chain(mkdir_dirs).collect();
        let chown_args: Vec<String> = vec!["-R".to_string(), owner, prefix.display().to_string()];
        if dry_run {
            miseprintln!("{}", sudo::argv("mkdir", &mkdir_args).join(" "));
            miseprintln!("{}", sudo::argv("chown", &chown_args).join(" "));

View on GitHub (pinned to 533346cc37)