{"record":{"id":"b0cf20846e054d86","repo":"oraios/serena","slug":"serena-configuration-file-not-found-config-file","errorCode":null,"errorMessage":"Serena configuration file not found: {config_file_path}","messagePattern":"Serena configuration file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/config/serena_config.py","lineNumber":1036,"sourceCode":"            old_config_path = os.path.join(REPO_ROOT, cls.CONFIG_FILE)\n            if os.path.exists(old_config_path):\n                log.info(f\"Moving Serena configuration file from {old_config_path} to {config_path}\")\n                os.makedirs(os.path.dirname(config_path), exist_ok=True)\n                shutil.move(old_config_path, config_path)\n\n        return config_path\n\n    @classmethod\n    def from_config_file(cls, generate_if_missing: bool = True) -> \"SerenaConfig\":\n        \"\"\"\n        Static constructor to create SerenaConfig from the configuration file\n        \"\"\"\n        config_file_path = cls._determine_config_file_path()\n\n        # create the configuration file from the template if necessary\n        if not os.path.exists(config_file_path):\n            if not generate_if_missing:\n                raise FileNotFoundError(f\"Serena configuration file not found: {config_file_path}\")\n            log.info(f\"Serena configuration file not found at {config_file_path}, autogenerating...\")\n            cls._generate_config_file(config_file_path)\n\n        # load the configuration\n        log.info(f\"Loading Serena configuration from {config_file_path}\")\n        try:\n            loaded_commented_yaml = load_yaml(config_file_path)\n        except Exception as e:\n            raise ValueError(f\"Error loading Serena configuration from {config_file_path}: {e}\") from e\n\n        # create the configuration instance\n        instance = cls(_loaded_commented_yaml=loaded_commented_yaml, _config_file_path=config_file_path)\n        num_migrations = 0\n\n        def get_value_or_default(field_name: str) -> Any:\n            nonlocal num_migrations\n            if field_name not in loaded_commented_yaml:\n                num_migrations += 1","sourceCodeStart":1018,"sourceCodeEnd":1054,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/config/serena_config.py#L1018-L1054","documentation":"SerenaConfig.from_config_file() locates the global serena_config.yml and, if it is missing, either autogenerates it from the bundled template or, when generate_if_missing=False, raises FileNotFoundError. The error tells you the user-level Serena configuration has not been initialized.","triggerScenarios":"Calling SerenaConfig.from_config_file(generate_if_missing=False) (or load()/make_agent()/main() paths that pass it) before any serena_config.yml exists in ~/.serena (or the determined config directory).","commonSituations":"Fresh install where `serena` was never run once; running in a container/CI with a non-existent HOME; SERENA_HOME-like env var pointing at an empty dir; programmatically loading config with generate_if_missing=False in tests.","solutions":["Run SerenaConfig.from_config_file(generate_if_missing=True) once, or `serena` CLI, to autogenerate the config from the template.","Manually create serena_config.yml in the config directory (copy the shipped template) including a `projects` key.","Check _determine_config_file_path()'s resolved location (HOME/env vars) matches where you placed the file."],"exampleFix":"// before\nconfig = SerenaConfig.from_config_file()  # FileNotFoundError on fresh machine\n// after\nconfig = SerenaConfig.from_config_file(generate_if_missing=True)","handlingStrategy":"try-catch","validationCode":"from serena.config.serena_config import SerenaConfig\npath = SerenaConfig._determine_config_file_path()\nimport os\nconfig_missing = not os.path.exists(path)","typeGuard":"def serena_config_exists() -> bool:\n    import os\n    from serena.config.serena_config import SerenaConfig\n    return os.path.exists(SerenaConfig._determine_config_file_path())","tryCatchPattern":"try:\n    config = SerenaConfig.from_config_file(generate_if_missing=False)\nexcept FileNotFoundError:\n    config = SerenaConfig.from_config_file(generate_if_missing=True)","preventionTips":["Run the serena CLI once on a fresh machine/container to bootstrap the config","Pin the config directory (env/HOME) in CI so the file is where you expect","Commit or template serena_config.yml for reproducible environments"],"tags":["configuration","file-not-found","python"],"backgroundTag":"config-file-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}