jdx/mise · error

agent ' ' `nice` must be between -20 and 20

Error message

agent '{name}' `nice` must be between -20 and 20

What it means

launchd's `nice` value (process priority) must be between -20 (highest priority) and 20 (lowest). LaunchdRequest::from_toml validates any configured nice value against this inclusive range and bails otherwise. This prevents generating a plist launchd would reject or misinterpret.

Solutions

  1. Change nice to a value within -20..=20
  2. Use nice = 0 for default priority
  3. Omit `nice` entirely if priority tuning is not needed

Example fix

# before
[agent.indexer]
program = "/usr/bin/indexer"
nice = -30
# after
[agent.indexer]
program = "/usr/bin/indexer"
nice = 10
Defensive patterns

Strategy: validation

Validate before calling

nice = agent_cfg.get("nice")
if nice is not None and not (-20 <= nice <= 20):
    raise ValueError(f"nice {nice} out of range")

Prevention

When it happens

Trigger: Setting nice = -30, nice = 25, or any value outside [-20, 20] in an agent config (config.nice is Some and out of range).

Common situations: Copying Unix renice conventions where -20..19 differ slightly; typos like -200; intending 'very high priority' with values below -20.

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/9b51a4d0343cbf55. Report an issue: GitHub.

Appendix: source

Thrown at src/system/launchd.rs:124

    pub state: LaunchdState,
}

impl LaunchdRequest {
    pub(crate) fn from_toml(name: String, config: LaunchdTomlConfig) -> Result<Self> {
        if !valid_name(&name) {
            bail!("agent name '{name}' must contain only letters, numbers, '.', '_', or '-'");
        }
        let Some(program) = config.program.map(|s| s.trim().to_string()) else {
            bail!("agent '{name}' must set `program`");
        };
        if program.is_empty() {
            bail!("agent '{name}' must set a non-empty `program`");
        }
        if config.keep_alive && config.keep_alive_on_failure {
            bail!("agent '{name}' cannot set both `keep_alive` and `keep_alive_on_failure`");
        }
        if config.nice.is_some_and(|nice| !(-20..=20).contains(&nice)) {
            bail!("agent '{name}' `nice` must be between -20 and 20");
        }
        if let Some(interval) = &config.start_calendar_interval {
            interval.validate(&name)?;
        }
        for dir in &config.queue_directories {
            if dir.trim().is_empty() {
                bail!("agent '{name}' `queue_directories` must not contain empty entries");
            }
            // checked against the raw string rather than `Path::is_absolute` on the
            // expanded value: the plist is consumed by macOS launchd, so POSIX rules
            // apply regardless of the platform parsing the config, and on Windows
            // `Path::new("/var/spool").is_absolute()` is false (root, but no prefix)
            if !is_absolute_launchd_path(dir) {
                bail!(
                    "agent '{name}' `queue_directories` entry '{dir}' must be an absolute path \
                     (launchd requires absolute paths; `~` and `~/` are expanded)"
                );
            }

View on GitHub (pinned to 533346cc37)