uutils/coreutils · error

invalid utmp path file

Error message

invalid utmp path file

What it means

Error "invalid utmp path file" thrown in uutils/coreutils.

Source

Thrown at src/uu/uptime/src/platform/unix.rs:145

        }
        user_count = count;
    }

    #[cfg(any(target_os = "openbsd", target_os = "android"))]
    {
        let upsecs = get_uptime(None)?;
        if upsecs >= 0 {
            print_uptime(Some(upsecs))?;
        } else {
            show_error!("{}", translate!("uptime-error-couldnt-get-boot-time"));
            set_exit_code(1);

            write!(stdout(), "{}", translate!("uptime-output-unknown-uptime"))?;
        }
        #[cfg(target_os = "openbsd")]
        {
            user_count =
                uucore::uptime::get_nusers(file_path.to_str().expect("invalid utmp path file"));
        }
        #[cfg(target_os = "android")]
        {
            user_count = 0;
        }
    }

    print_nusers(Some(user_count))?;
    print_loadavg()?;

    Ok(())
}

#[cfg(not(any(target_os = "openbsd", target_os = "android")))]
fn process_utmpx(file: Option<&OsString>) -> (Option<time_t>, usize) {
    let mut nusers = 0;
    let mut boot_time = None;

View on GitHub (pinned to 8b8cbfd51b)

Solutions

  1. Provide a valid utmp/wtmp file path (e.g. /var/run/utmp) that exists and is readable.
  2. Run on a system that maintains utmp records, or install the equivalent logging service.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Occurs when uptime is given a utmp file path that is invalid or cannot be used.

Common situations: Pointing uptime at a missing, unreadable, or malformed utmp/wtmp file.


AI-assisted analysis of uutils/coreutils@8b8cbfd51b (2026-08-24). Data as JSON: /api/errors/878ca35e7267a494. Report an issue: GitHub.