rust-lang/rust · error · RuntimeError

failed to find config line for {}

Error message

failed to find config line for {}

What it means

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.

Source

Thrown at src/bootstrap/configure.py:720


def configure_section(lines, config):
    for key in config:
        value = config[key]
        found = False
        for i, line in enumerate(lines):
            if not line.startswith("#" + key + " = "):
                continue
            found = True
            lines[i] = "{} = {}".format(key, to_toml(value))
            break
        if not found:
            # These are used by rpm, but aren't accepted by x.py.
            # Give a warning that they're ignored, but not a hard error.
            if key in ["infodir", "localstatedir"]:
                print("WARNING: {} will be ignored".format(key))
            else:
                raise RuntimeError("failed to find config line for {}".format(key))


def configure_top_level_key(lines, top_level_key, value):
    for i, line in enumerate(lines):
        if line.startswith("#" + top_level_key + " = ") or line.startswith(
            top_level_key + " = "
        ):
            lines[i] = "{} = {}".format(top_level_key, to_toml(value))
            return

    raise RuntimeError("failed to find config line for {}".format(top_level_key))


# Modify `sections` to reflect the parsed arguments and example configs.
def configure_file(sections, top_level_keys, targets, config):
    for section_key, section_config in config.items():
        if section_key not in sections and section_key not in top_level_keys:
            raise RuntimeError(

View on GitHub (pinned to 7088e4b63a)

Solutions

  1. Check the config.toml template (src/bootstrap/defaults/) for the section to find available commented-out keys.
  2. Correct the key name or move it to the correct section in the configure invocation.
  3. If the option is valid but missing from the template, add a commented-out '#<key> = ""' line to the appropriate section template.
Defensive patterns

Strategy: validation

Validate before calling

# Before calling configure_section, verify the key has a template line
def validate_section_key(lines, key):
    for line in lines:
        if line.startswith('#' + key + ' = '):
            return True
    if key in ['infodir', 'localstatedir']:
        return True  # intentionally ignored
    return False

Try / catch

try:
    configure_section(lines, config)
except RuntimeError as e:
    if 'failed to find config line for' in str(e):
        key = str(e).split('for ')[-1]
        print(f'Key {key} has no template in the config section.')
        print('Add a commented-out line: #{} = ""'.format(key))
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10). Data as JSON: /api/errors/14b0e404ccaf10e7. Report an issue: GitHub.