jdx/mise · error

collection updates require scalar or array values

Error message

collection updates require scalar or array values

What it means

The `values` helper in `mise config set` converts an existing TOML item into a list of values for append/remove operations. It only supports an existing TOML array (returns its elements) or a single scalar value (wraps it in a one-element vec). If the targeted key holds a table (or is otherwise not a value), there is no sensible element list, so it bails with 'collection updates require scalar or array values'.

Source

Thrown at src/cli/config/set.rs:253

        } else {
            table.insert(last_key, value);
        }

        let raw = config.to_string();
        MiseToml::from_str(&raw, &file)?;
        if let Some(parent) = file.parent() {
            std::fs::create_dir_all(parent)?;
        }
        std::fs::write(&file, raw)?;
        Ok(())
    }
}

fn values(item: toml_edit::Item) -> eyre::Result<Vec<toml_edit::Value>> {
    match item {
        toml_edit::Item::Value(toml_edit::Value::Array(array)) => Ok(array.into_iter().collect()),
        toml_edit::Item::Value(value) => Ok(vec![value]),
        _ => bail!("collection updates require scalar or array values"),
    }
}

fn values_equal(left: &toml_edit::Value, right: &toml_edit::Value) -> bool {
    if let (Some(left), Some(right)) = (left.as_str(), right.as_str()) {
        return left == right;
    }
    if let (Some(left), Some(right)) = (left.as_integer(), right.as_integer()) {
        return left == right;
    }
    if let (Some(left), Some(right)) = (left.as_float(), right.as_float()) {
        return left == right;
    }
    if let (Some(left), Some(right)) = (left.as_bool(), right.as_bool()) {
        return left == right;
    }
    if let (Some(left), Some(right)) = (left.as_datetime(), right.as_datetime()) {
        return left == right;

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Target the specific scalar or array key inside the table instead of the table itself (e.g. `env.MY_LIST` not `env`)
  2. Verify the current value with `mise config get <key>` to confirm it is a scalar or array before appending/removing
  3. Create the key as an array first (via `mise config set` with an array type) if it does not exist yet

Example fix

// before
mise config set --append env.list 3   # env is a table -> error
// after
mise config set --append env.MY_LIST 3
Defensive patterns

Strategy: validation

Validate before calling

val=$(mise config get "$KEY")
if [[ "$val" == *'{'* ]]; then echo "$KEY is a table; target a scalar/array child"; exit 1; fi

Try / catch

if let Err(e) = result {
    if e.to_string().contains("collection updates require scalar or array values") {
        // target a child key or create the key as an array first
    }
}

Prevention

When it happens

Trigger: Calling `mise config set --append` or `--remove` on a key that currently resolves to a TOML table (nested config section) or to a non-value item (e.g. missing/none), via append_value or remove_value.

Common situations: Trying to append to a key that is actually a subsection like `[env]` or `[settings.something]` with children, or a typo in the key path that lands on a table instead of the intended scalar/array.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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