{"record":{"id":"303faacfe9bb1c75","repo":"rust-lang/cargo","slug":"unexpected-btype-bracket-literal-in-build-bu","errorCode":null,"errorMessage":"unexpected {btype} bracket `{literal}` in build.build-dir path `{raw_template}`","messagePattern":"unexpected (.+?) bracket `(.+?)` in build\\.build-dir path `(.+?)`","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/context/mod.rs","lineNumber":809,"sourceCode":"                    variable,\n                    raw_template,\n                } => {\n                    let mut suggestion = closest_msg(&variable, template_variables.iter(), |key| key, \"template variable\");\n                    if suggestion == \"\" {\n                        let variables = template_variables.iter().map(|v| format!(\"`{{{v}}}`\")).join(\", \");\n                        suggestion = format!(\"\\n\\nhelp: available template variables are {variables}\");\n                    }\n                    anyhow!(\n                            \"unexpected variable `{variable}` in build.build-dir path `{raw_template}`{suggestion}\"\n                        )\n                }\n                path::ResolveTemplateError::UnexpectedBracket { bracket_type, raw_template } => {\n                    let (btype, literal) = match bracket_type {\n                        path::BracketType::Opening => (\"opening\", \"{\"),\n                        path::BracketType::Closing => (\"closing\", \"}\"),\n                    };\n\n                    anyhow!(\n                            \"unexpected {btype} bracket `{literal}` in build.build-dir path `{raw_template}`\"\n                        )\n                }\n            })?;\n\n        // Check if the target directory is set to an empty string in the config.toml file.\n        if val.raw_value().is_empty() {\n            bail!(\n                \"the build directory is set to an empty string in {}\",\n                val.value().definition\n            )\n        }\n\n        Ok(Filesystem::new(path))\n    }\n\n    /// Get a configuration value by key.\n    ///","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/context/mod.rs#L791-L827","documentation":"Thrown when resolving the build.build-dir template path and encountering a curly brace that is not part of a valid variable — either an opening brace { without a matching closing brace }, or a closing brace } without a preceding opening brace.","triggerScenarios":"Setting build.build-dir to a path with mismatched braces, e.g. `{user/target`, `user}/target`, or a stray brace in a directory name.","commonSituations":"Typo in the template syntax. Copy-pasting a path that accidentally includes a brace character. Directory name that legitimately contains a brace character but is not intended as a template.","solutions":["Ensure every opening brace { has a matching closing brace }","If the path legitimately needs a literal brace character, this is not currently supported — use a different path","Remove the template syntax entirely and use a plain path if template variables are not needed"],"exampleFix":"# before (config.toml)\n[build]\nbuild-dir = \"{user/target\"\n\n# after\n[build]\nbuild-dir = \"{user}/target\"","handlingStrategy":"validation","validationCode":"// Check for balanced braces in template strings\nfn validate_braces(s: &str) -> Result<(), String> {\n    let mut depth = 0;\n    for (i, c) in s.chars().enumerate() {\n        match c {\n            '{' => depth += 1,\n            '}' => { depth -= 1; if depth < 0 { return Err(format!(\"unmatched closing brace at position {i}\")); } }\n            _ => {}\n        }\n    }\n    if depth != 0 { return Err(\"unmatched opening brace\".into()); }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair { with } in build-dir paths","Avoid literal brace characters in directory names","Use a linter or editor plugin that highlights unbalanced braces"],"tags":["configuration","build-dir","template","syntax"],"backgroundTag":null,"analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}