cross-rs/cross · warning

a target named " " is mentioned in the Cross configuration…

Error message

a target named "{mentioned_target}" is mentioned in the Cross configuration, but the current specified target is "{target}".

What it means

`confusable_target` (src/config.rs:262) warns when a target mentioned in the Cross configuration (e.g. a `[target.<triple>]` section) normalizes to the same string as the current target after stripping `-`/`_` and lowercasing, but is not byte-identical. Cross proceeds but warns that the target may be misspelled, since config keys like `aarch64-linux-android` vs `aarch64_linux_android` style mismatches can silently not apply.

Solutions

  1. Make the target name in Cross.toml exactly match the specified target triple, using hyphens (`[target.aarch64-unknown-linux-gnu]`)
  2. Re-run cross after fixing; the warning disappears when mentioned_target == target
  3. If intentional (e.g. custom target with underscores), rename the config key or ignore the warning — it does not abort the build

Example fix

// before (Cross.toml)
[target.x86_64_unknown_linux_gnu]
image = "my-image"
// after
[target.x86_64-unknown-linux-gnu]
image = "my-image"
Defensive patterns

Strategy: validation

Validate before calling

// normalize config target keys the same way cross does before writing Cross.toml
fn norm(s: &str) -> String { s.replace(['-','_'], "").to_lowercase() }
assert_eq!(norm("x86_64_unknown_linux_gnu"), norm("x86_64-unknown-linux-gnu"));
// then fix the key to the exact triple: [target.x86_64-unknown-linux-gnu]

Prevention

When it happens

Trigger: A `[target.X]` table or `target.X` key in Cross.toml/config where X differs from the build target only by hyphen vs underscore or letter case (e.g. configured `x86_64_unknown_linux_gnu` while building `x86_64-unknown-linux-gnu`).

Common situations: Copy-pasting target triples with underscores from older docs or other tools, hand-typing triples with wrong casing, or mixing target-JSON custom target names with std triples.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of cross-rs/cross@8c1a8aa4b6 (2026-09-13). Data as JSON: /api/errors/b1511142a5019ebd. Report an issue: GitHub.

Appendix: source

Thrown at src/config.rs:262

impl Config {
    pub fn new(toml: Option<CrossToml>) -> Self {
        Config {
            toml,
            env: Environment::new(None),
        }
    }

    pub fn confusable_target(&self, target: &Target, msg_info: &mut MessageInfo) -> Result<()> {
        if let Some(keys) = self.toml.as_ref().map(|t| t.targets.keys()) {
            for mentioned_target in keys {
                let mentioned_target_norm = mentioned_target
                    .to_string()
                    .replace(['-', '_'], "")
                    .to_lowercase();
                let target_norm = target.to_string().replace(['-', '_'], "").to_lowercase();
                if mentioned_target != target && mentioned_target_norm == target_norm {
                    msg_info.warn(format_args!("a target named \"{mentioned_target}\" is mentioned in the Cross configuration, but the current specified target is \"{target}\"."))?;
                    msg_info.status(" > Is the target misspelled in the Cross configuration?")?;
                }
            }
        }
        Ok(())
    }

    fn get_from_value_inner<T, U>(
        &self,
        target: &Target,
        env: impl for<'a> FnOnce(&'a Environment, &Target) -> ConfVal<T>,
        config: impl for<'a> FnOnce(&'a CrossToml, &Target) -> ConfVal<Cow<'a, U>>,
    ) -> Option<T>
    where
        U: ToOwned<Owned = T> + ?Sized,
    {
        let env = env(&self.env, target);
        let toml = self

View on GitHub (pinned to 8c1a8aa4b6)