{"record":{"id":"dee57b005910b7d8","repo":"jdx/mise","slug":"brew-cask-invalid-command-wrapper-environment-nam","errorCode":null,"errorMessage":"brew-cask: invalid command_wrapper environment name '{key}'","messagePattern":"brew-cask: invalid command_wrapper environment name '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask.rs","lineNumber":5183,"sourceCode":"                .iter()\n                .map(|arg| {\n                    arg.as_str()\n                        .map(str::to_string)\n                        .ok_or_else(|| eyre!(\"brew-cask: command_wrapper args must be strings\"))\n                })\n                .collect::<Result<Vec<_>>>()\n        })\n        .transpose()?\n        .unwrap_or_default();\n    let env = options\n        .get(\"env\")\n        .map(|env| {\n            env.as_object()\n                .ok_or_else(|| eyre!(\"brew-cask: command_wrapper env must be an object\"))?\n                .iter()\n                .map(|(key, value)| {\n                    if !is_shell_env_name(key) {\n                        bail!(\"brew-cask: invalid command_wrapper environment name '{key}'\");\n                    }\n                    value\n                        .as_str()\n                        .map(|value| (key.clone(), value.to_string()))\n                        .ok_or_else(|| {\n                            eyre!(\"brew-cask: command_wrapper environment values must be strings\")\n                        })\n                })\n                .collect::<Result<BTreeMap<_, _>>>()\n        })\n        .transpose()?\n        .unwrap_or_default();\n    if content.is_some() && (!args.is_empty() || !env.is_empty()) {\n        bail!(\"brew-cask: command_wrapper args and env require executable\");\n    }\n    Ok(Some(CommandWrapperArtifact {\n        name: name.to_string(),\n        target: artifact_target(value, values),","sourceCodeStart":5165,"sourceCodeEnd":5201,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L5165-L5201","documentation":"Each key of a command_wrapper's 'env' map becomes an environment variable in the generated bash wrapper, so mise validates it with is_shell_env_name: first character must be '_' or an ASCII letter, all remaining characters '_' or ASCII alphanumeric. Keys with dashes, dots, spaces, or a leading digit are rejected with the offending key named in the message.","triggerScenarios":"An env map like {\"MY-VAR\": \"1\"}, {\"1VAR\": \"x\"}, or {\"MY.VAR\": \"y\"} — any key failing the character rule implemented at src/system/packages/brew/cask.rs:4678 and enforced at :5183.","commonSituations":"Authors copying env names that are valid elsewhere (HTTP-Proxy in launchd plists, my.tool.opts in config files) but illegal as shell identifiers; hyphenated names that silently break the generated wrapper; metadata written from a JSON schema without identifier constraints.","solutions":["Rename the variable to a valid shell identifier: MY-VAR -> MY_VAR, 1VAR -> VAR1.","If the wrapped program truly requires an odd name, pass it via 'args' or set it inside 'content' instead of the env map.","Validate env keys with the same rule in your metadata generator."],"exampleFix":"# before\ncommand_wrapper: [[\"tool\", {\"executable\": \"bin/tool\", \"env\": {\"MY-VAR\": \"1\"}}]]\n\n# after\ncommand_wrapper: [[\"tool\", {\"executable\": \"bin/tool\", \"env\": {\"MY_VAR\": \"1\"}}]]","handlingStrategy":"type-guard","validationCode":"fn is_shell_env_name_like(v: &str) -> bool {\n    let mut c = v.chars();\n    c.next().is_some_and(|f| f == '_' || f.is_ascii_alphabetic())\n        && c.all(|r| r == '_' || r.is_ascii_alphanumeric())\n}","typeGuard":"function isShellEnvName(name) {\n  return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);\n}","tryCatchPattern":null,"preventionTips":["Use snake_case UPPER_SHELL_NAMES for every env key in wrapper metadata.","Reject keys containing '-', '.', or leading digits in your metadata validator.","For exotic names the program requires, set them inside 'content' instead of the env map."],"tags":["brew-cask","command-wrapper","env-var-name","validation","mise"],"backgroundTag":"invalid-env-var-name","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}