jdx/mise · error

service unit ' ' has invalid `nice` value ; expected -20…

Error message

service unit '{name}' has invalid `nice` value {nice}; expected -20 through 19

What it means

from_toml validates the optional `nice` priority against the OS range -20 (highest priority) through 19 (lowest). Values outside this range would be rejected by systemd/setpriority anyway, so mise fails fast at config parse time.

Solutions

  1. Change nice to a value between -20 and 19 inclusive (lower = higher priority)
  2. Remember values below 0 usually require root; pick >= 0 for unprivileged units
  3. Remove the nice key if prioritization is not needed

Example fix

# before (mise.toml)
[systemd."worker.service"]
exec_start = "/usr/bin/worker"
nice = 20
# after
[systemd."worker.service"]
exec_start = "/usr/bin/worker"
nice = 19
Defensive patterns

Strategy: validation

Validate before calling

fn valid_nice(n: i32) -> bool { (-20..=19).contains(&n) }
// check before writing nice into the unit config

Prevention

When it happens

Trigger: Setting nice in a systemd unit's TOML config in mise.toml to any integer not in -20..=19 (e.g. nice = 20 or nice = -21) and loading the config via SystemdRequest::from_toml.

Common situations: Confusing nice range with the -20..20 exclusive bound; using a Unix priority value from another tool with a different convention; off-by-one typos like -25.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at src/system/systemd.rs:221

                    "timer unit '{name}' cannot set service-only directive(s): {}",
                    service_only_fields.join(", ")
                );
            }
            if config.on_boot_sec.is_none()
                && config.on_unit_active_sec.is_none()
                && config.on_unit_inactive_sec.is_none()
                && config.on_calendar.is_none()
            {
                bail!(
                    "timer unit '{name}' must set at least one of `on_boot_sec`, \
                     `on_unit_active_sec`, `on_unit_inactive_sec`, or `on_calendar`"
                );
            }
        }
        if let Some(nice) = config.nice
            && !(-20..=19).contains(&nice)
        {
            bail!("service unit '{name}' has invalid `nice` value {nice}; expected -20 through 19");
        }
        if let Some(umask) = &config.umask
            && !valid_umask(umask)
        {
            bail!(
                "service unit '{name}' has invalid `umask` value '{umask}'; expected an octal access mask from 0000 through 0777"
            );
        }
        let wanted_by = config.wanted_by.unwrap_or_else(|| match kind {
            SystemdUnitKind::Service => vec!["default.target".to_string()],
            SystemdUnitKind::Timer => vec!["timers.target".to_string()],
        });
        Ok(Self {
            unit: format!(
                "dev.mise.{name}.{}",
                match kind {
                    SystemdUnitKind::Service => "service",
                    SystemdUnitKind::Timer => "timer",

View on GitHub (pinned to 533346cc37)