astrid-runtime/astrid · error

Cargo rustflags must be a string or array in

Error message

Cargo rustflags must be a string or array in {}

What it means

Type-dispatch fallback in parse_rustflags: the rustflags value in the Cargo config is neither an array nor a string — the only supported encodings. Anything else (integer, boolean, nested table) cannot be split into compiler flags, so absorb_document aborts and names the offending config file.

Solutions

  1. Use `rustflags = ["-C", "..."]` array form or a single quoted string
  2. Fix the TOML type in the offending config file
  3. Remove unrelated keys from rustflags
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/astrid-build/src/rust/config.rs:424 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/3877cbd83c8c8cb5. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-build/src/rust/config.rs:424

                    anyhow::anyhow!(
                        "Cargo rustflags array contains a non-string value in {}",
                        path.display()
                    )
                })
            })
            .collect::<Result<Vec<_>>>()?;
        return Ok(ParsedRustflags {
            flags,
            is_array: true,
        });
    }
    if let Some(value) = item.as_str() {
        return Ok(ParsedRustflags {
            flags: value.split_whitespace().map(str::to_owned).collect(),
            is_array: false,
        });
    }
    bail!(
        "Cargo rustflags must be a string or array in {}",
        path.display()
    )
}

fn merge_rustflags(slot: &mut Option<ParsedRustflags>, incoming: ParsedRustflags) {
    if let Some(existing) = slot
        && existing.is_array
        && incoming.is_array
    {
        existing.flags.extend(incoming.flags);
    } else {
        *slot = Some(incoming);
    }
}

pub(super) fn cargo_home_from_env(dir: &Path) -> Option<PathBuf> {
    if let Some(home) = std::env::var_os("CARGO_HOME")

View on GitHub (pinned to affd8760f4)