FoundationAgents/MetaGPT · error · FileNotFoundError

Configuration file '{FILE_NAME}' not found in settings direc

Error message

Configuration file '{FILE_NAME}' not found in settings directory

What it means

load_meta_data builds a path metagpt/ext/spo/settings/<FILE_NAME> and raises FileNotFoundError when it does not exist. FILE_NAME is a module global that is empty until set_file_name(name) is called, so forgetting to set it — or setting a name with no matching yaml in the settings directory — both produce this error.

Source

Thrown at metagpt/ext/spo/utils/load.py:20

from pathlib import Path

import yaml

FILE_NAME = ""
SAMPLE_K = 3


def set_file_name(name: str):
    global FILE_NAME
    FILE_NAME = name


def load_meta_data(k: int = SAMPLE_K):
    # load yaml file
    config_path = Path(__file__).parent.parent / "settings" / FILE_NAME

    if not config_path.exists():
        raise FileNotFoundError(f"Configuration file '{FILE_NAME}' not found in settings directory")

    try:
        with config_path.open("r", encoding="utf-8") as file:
            data = yaml.safe_load(file)
    except yaml.YAMLError as e:
        raise ValueError(f"Error parsing YAML file '{FILE_NAME}': {str(e)}")
    except Exception as e:
        raise Exception(f"Error reading file '{FILE_NAME}': {str(e)}")

    qa = []

    for item in data["qa"]:
        question = item["question"]
        answer = item["answer"]
        qa.append({"question": question, "answer": answer})

    prompt = data["prompt"]
    requirements = data["requirements"]

View on GitHub (pinned to 11cdf466d0)

Solutions

  1. Call set_file_name('your_file.yaml') before load_meta_data().
  2. Confirm the file exists at metagpt/ext/spo/settings/your_file.yaml (exact name, .yaml not .yml or vice versa).
  3. If using a custom location, copy/symlink the yaml into the settings directory or adjust the path resolution.

Example fix

// before
from metagpt.ext.spo.utils.load import load_meta_data
data = load_meta_data()  # FILE_NAME is "" -> path does not exist

// after
from metagpt.ext.spo.utils.load import set_file_name, load_meta_data
set_file_name("CodeGeneration.yaml")
data = load_meta_data()
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
from metagpt.ext.spo.utils import load

def settings_file_ready(name: str) -> bool:
    p = Path(load.__file__).parent.parent / "settings" / name
    return p.is_file()

assert settings_file_ready("CodeGeneration.yaml"), "settings yaml missing"

Try / catch

try:
    data = load_meta_data()
except FileNotFoundError as e:
    raise FileNotFoundError(f"check set_file_name + metagpt/ext/spo/settings/: {e}") from e

Prevention

When it happens

Trigger: Calling load_meta_data() before set_file_name('my_settings.yaml'); passing a file name that differs from the actual file in metagpt/ext/spo/settings/ (wrong extension, typo, leading path component).

Common situations: New SPO experiments where the developer created a custom settings yaml but forgot the set_file_name call; renaming yaml files without updating the caller; assuming load_meta_data takes the file name as an argument instead of using the global.

Related errors


AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14). Data as JSON: /api/errors/84661101cb9002a3. Report an issue: GitHub.