{"record":{"id":"c2eb781985347091","repo":"cross-rs/cross","slug":"got-var-type-of-var-which-is-not-a-valid-environment","errorCode":null,"errorMessage":"got {var_type} of \"{var}\" which is not a valid environment variable name. the proper syntax is {var_syntax}","messagePattern":"got (.+?) of \"(.+?)\" which is not a valid environment variable name\\. the proper syntax is (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/docker/shared.rs","lineNumber":896,"sourceCode":"fn validate_env_var<'a>(\n    var: &'a str,\n    warned: &mut bool,\n    var_type: &'static str,\n    var_syntax: &'static str,\n    msg_info: &mut MessageInfo,\n) -> Result<(&'a str, Option<&'a str>)> {\n    let (key, value) = match var.split_once('=') {\n        Some((key, value)) => (key, Some(value)),\n        _ => (var, None),\n    };\n\n    if value.is_none()\n        && !*warned\n        && !var\n            .chars()\n            .all(|c| matches!(c, 'a'..='z' | 'A'..='Z' | '_' | '0'..='9'))\n    {\n        msg_info.warn(format_args!(\n            \"got {var_type} of \\\"{var}\\\" which is not a valid environment variable name. the proper syntax is {var_syntax}\"\n        ))?;\n        *warned = true;\n    }\n\n    if key == \"CROSS_RUNNER\" {\n        eyre::bail!(\n            \"CROSS_RUNNER environment variable name is reserved and cannot be pass through\"\n        );\n    }\n\n    Ok((key, value))\n}\n\nimpl CommandVariant {\n    pub(crate) fn safe_command(&self) -> SafeCommand {\n        SafeCommand::new(self.to_str())\n    }","sourceCodeStart":878,"sourceCodeEnd":914,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/src/docker/shared.rs#L878-L914","documentation":"Generic validation guard in validate_env_var: a `-e VAR=value` / `--env` / `--set-env` style argument passed to the container engine was split on '=' and the name part (or the whole argument, when no '=' was present) contains characters outside [A-Za-z0-9_], so it cannot be a valid environment variable name. Fires at most once per invocation thanks to the `warned` flag, and is only emitted when no '=' was found, since names are still reported for key=value forms.","triggerScenarios":"Thrown at src/docker/shared.rs:896 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the argument to use only letters, digits and underscores in the variable name, e.g. `-e MY_VAR=value`","Include an `=` with a value if you meant to set a variable rather than pass one through from the host","Check for shell quoting problems that inject stray characters (spaces, dashes, newlines) into the env argument"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}