jdx/mise · error
service unit '{name}' has invalid `nice` value {nice}; expec
Error message
service unit '{name}' has invalid `nice` value {nice}; expected -20 through 19 What it means
The optional `nice` value for a service unit must be within the kernel's valid range of -20 (highest priority) through 19 (lowest). `from_toml` validates this before generating the unit file so systemd does not reject it later.
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 afd2eddd3a)
Solutions
- Change `nice` to a value between -20 and 19 (e.g. `nice = 10`).
- Note that negative nice values typically require root/CAP_SYS_NICE at runtime; prefer a non-negative value if the service runs unprivileged.
- Remove the `nice` key entirely if priority tuning is not needed.
Example fix
# before [systemd.myapp] exec_start = "/usr/bin/myapp" nice = 25 # after [systemd.myapp] exec_start = "/usr/bin/myapp" nice = 10
Defensive patterns
Strategy: validation
Validate before calling
fn valid_nice(n: i32) -> bool { (-20..=19).contains(&n) }
assert!(valid_nice(10) && !valid_nice(25)); Prevention
- Clamp nice values to -20..=19 when generating configs programmatically.
- Prefer non-negative nice values for unprivileged services.
- Don't copy nice ranges from other tools with different bounds.
When it happens
Trigger: Setting `nice` to any integer outside -20..=19 (e.g. `nice = 25` or `nice = -21`) in a `[systemd.<name>]` block that resolves to a Service.
Common situations: Off-by-one mistakes thinking the range is 0-19 (forgetting negatives are root-privileged); typos like `nice = -2O`; copying values from other tools with different ranges.
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
- agent '{name}' `nice` must be between -20 and 20
- bootstrap service '{name}' cannot be both masked and running
- bootstrap service '{name}' cannot be both masked and enabled
- invalid bootstrap service name '{name}': use at most 255 ASC
- unit name '{name}' must contain only letters, numbers, '.',
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/447ffacd123cdc8b.
Report an issue: GitHub.