{"record":{"id":"864339d8934fb53c","repo":"cross-rs/cross","slug":"invalid-linux-version-got-linux-version","errorCode":null,"errorMessage":"invalid linux version, got {linux_version}","messagePattern":"invalid linux version, got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/crosstool.rs","lineNumber":369,"sourceCode":"        configure_newlib(newlib_version)?\n    } else {\n        eyre::bail!(\"unsupported rust target for file {file_name}: unknown libc version\");\n    };\n    if libc.starts_with('\\n') {\n        libc.remove(0);\n    }\n    contents = contents\n        .replacen(&format!(\"%CT_{key}_V%\"), &libc_v, 1)\n        .replacen(&format!(\"%CT_{key}%\"), &libc, 1);\n    if let Some(extras) = extras {\n        contents = contents.replacen(&format!(\"%CT_{key}_EXTRAS%\"), &extras, 1);\n    }\n\n    // configure the `CT_LINUX` values\n    if file_name.contains(\"linux\") {\n        let linux_versions: Vec<&str> = linux_version.split('.').collect();\n        if !matches!(linux_versions.len(), 2 | 3) {\n            eyre::bail!(\"invalid linux version, got {linux_version}\");\n        }\n        let linux_major = linux_versions[0].parse::<u32>()?;\n        let linux_minor = linux_versions[1].parse::<u32>()?;\n        let linux_patch = linux_versions.get(2).unwrap_or(&\"0\").parse::<u32>()?;\n        let ct_linux_v = format!(\n            r#\"CT_LINUX_V_{linux_major}_{linux_minor}=y\n# CT_LINUX_NO_VERSIONS is not set\nCT_LINUX_VERSION=\"{linux_major}.{linux_minor}.{linux_patch}\"\"#\n        );\n        let mut ct_linux = String::new();\n        if linux_major < 4 || (linux_major == 4 && linux_minor < 8) {\n            ct_linux.push_str(\"\\nCT_LINUX_older_than_4_8=y\");\n            ct_linux.push_str(\"\\nCT_LINUX_4_8_or_older=y\");\n        } else {\n            ct_linux.push_str(\"\\nCT_LINUX_later_than_4_8=y\");\n            ct_linux.push_str(\"\\nCT_LINUX_4_8_or_later=y\");\n        }\n        if linux_major < 3 || (linux_major == 3 && linux_minor < 7) {","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/xtask/src/crosstool.rs#L351-L387","documentation":"configure_target validates the Linux kernel version string used to fill CT_LINUX template values. It must split on '.' into exactly 2 or 3 numeric components (major.minor[.patch]); otherwise it bails with this error. Subsequent parse::<u32> failures also surface as different errors, so this message specifically means the component count is wrong.","triggerScenarios":"configure_crosstool is invoked for a 'linux' target with linux_version like '6', '6.1.0.2' (four components), an empty string, or a string using separators other than dots.","commonSituations":"Misconfigured CI variable (e.g. 'v6.1' with a leading v, or '6-1'), passing a full kernel release string like '6.1.0-13-amd64' from `uname -r`, or an empty env var.","solutions":["Provide the version as major.minor or major.minor.patch, e.g. '6.1' or '6.1.55'","Strip a leading 'v' and any distro suffix from the kernel version before calling","Validate with a regex like ^\\d+\\.\\d+(\\.\\d+)?$ before invoking configure_crosstool"],"exampleFix":"// before\nlet linux_version = \"6.1.0-13-amd64\";\n// after\nlet linux_version = \"6.1.0\";","handlingStrategy":"validation","validationCode":"let re = regex::Regex::new(r\"^\\d+\\.\\d+(\\.\\d+)?$\").unwrap();\nassert!(re.is_match(linux_version), \"linux version must be major.minor[.patch], got: {linux_version}\");","typeGuard":"fn is_valid_linux_version(v: &str) -> bool {\n    let parts: Vec<&str> = v.split('.').collect();\n    (2..=3).contains(&parts.len()) && parts.iter().all(|p| p.parse::<u32>().is_ok())\n}","tryCatchPattern":"match configure_crosstool(&target) {\n    Ok(cfg) => cfg,\n    Err(e) if e.to_string().contains(\"invalid linux version\") => {\n        eprintln!(\"normalize LINUX_VERSION to X.Y[.Z] (strip 'v' and distro suffixes)\");\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Do not pass `uname -r` output directly — strip distro suffixes like '-13-amd64'","Strip a leading 'v' from version variables sourced from tags","Validate version format at the CI variable definition, not deep in the build"],"tags":["crosstool","version","validation","config"],"backgroundTag":"invalid-argument-format","analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}