{"record":{"id":"14b0e404ccaf10e7","repo":"rust-lang/rust","slug":"failed-to-find-config-line-for","errorCode":null,"errorMessage":"failed to find config line for {}","messagePattern":"failed to find config line for (.+?)","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/bootstrap/configure.py","lineNumber":720,"sourceCode":"\n\ndef configure_section(lines, config):\n    for key in config:\n        value = config[key]\n        found = False\n        for i, line in enumerate(lines):\n            if not line.startswith(\"#\" + key + \" = \"):\n                continue\n            found = True\n            lines[i] = \"{} = {}\".format(key, to_toml(value))\n            break\n        if not found:\n            # These are used by rpm, but aren't accepted by x.py.\n            # Give a warning that they're ignored, but not a hard error.\n            if key in [\"infodir\", \"localstatedir\"]:\n                print(\"WARNING: {} will be ignored\".format(key))\n            else:\n                raise RuntimeError(\"failed to find config line for {}\".format(key))\n\n\ndef configure_top_level_key(lines, top_level_key, value):\n    for i, line in enumerate(lines):\n        if line.startswith(\"#\" + top_level_key + \" = \") or line.startswith(\n            top_level_key + \" = \"\n        ):\n            lines[i] = \"{} = {}\".format(top_level_key, to_toml(value))\n            return\n\n    raise RuntimeError(\"failed to find config line for {}\".format(top_level_key))\n\n\n# Modify `sections` to reflect the parsed arguments and example configs.\ndef configure_file(sections, top_level_keys, targets, config):\n    for section_key, section_config in config.items():\n        if section_key not in sections and section_key not in top_level_keys:\n            raise RuntimeError(","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/bootstrap/configure.py#L702-L738","documentation":"Raised by configure_section() in configure.py at line 720. This function iterates over keys in a config section and tries to find each key's commented-out template line (starting with '#<key> = ') in the config template lines. If no such line exists, it cannot know where to write the value, so it raises a RuntimeError. The exception is skipped for 'infodir' and 'localstatedir' which are rpm-specific and intentionally ignored.","triggerScenarios":"configure_file() calls configure_section(sections[section_key], section_config) at line 748. For each key in section_config, configure_section scans lines[] for one starting with '#' + key + ' = '. If none matches (line 714: not found), and the key is not infodir/localstatedir, RuntimeError is raised at line 720.","commonSituations":"Passing a configure option via --set or --enable-* that doesn't have a corresponding commented template in the config.toml template for that section (e.g. a typo, or an option that belongs to a different section, or a newly added option whose template hasn't been added to the defaults file).","solutions":["Check the config.toml template (src/bootstrap/defaults/) for the section to find available commented-out keys.","Correct the key name or move it to the correct section in the configure invocation.","If the option is valid but missing from the template, add a commented-out '#<key> = \"\"' line to the appropriate section template."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Before calling configure_section, verify the key has a template line\ndef validate_section_key(lines, key):\n    for line in lines:\n        if line.startswith('#' + key + ' = '):\n            return True\n    if key in ['infodir', 'localstatedir']:\n        return True  # intentionally ignored\n    return False","typeGuard":null,"tryCatchPattern":"try:\n    configure_section(lines, config)\nexcept RuntimeError as e:\n    if 'failed to find config line for' in str(e):\n        key = str(e).split('for ')[-1]\n        print(f'Key {key} has no template in the config section.')\n        print('Add a commented-out line: #{} = \"\"'.format(key))\n    raise","preventionTips":["Only configure keys that have commented-out template lines in the config.toml defaults.","Check the defaults file for the target section before passing --set options.","When adding new configurable options, add the corresponding commented template line."],"tags":["bootstrap","rustc","configure","config","python"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}