oraios/serena · error · FileNotFoundError
Serena configuration file not found: {config_file_path}
Error message
Serena configuration file not found: {config_file_path} What it means
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.
Source
Thrown at src/serena/config/serena_config.py:1036
old_config_path = os.path.join(REPO_ROOT, cls.CONFIG_FILE)
if os.path.exists(old_config_path):
log.info(f"Moving Serena configuration file from {old_config_path} to {config_path}")
os.makedirs(os.path.dirname(config_path), exist_ok=True)
shutil.move(old_config_path, config_path)
return config_path
@classmethod
def from_config_file(cls, generate_if_missing: bool = True) -> "SerenaConfig":
"""
Static constructor to create SerenaConfig from the configuration file
"""
config_file_path = cls._determine_config_file_path()
# create the configuration file from the template if necessary
if not os.path.exists(config_file_path):
if not generate_if_missing:
raise FileNotFoundError(f"Serena configuration file not found: {config_file_path}")
log.info(f"Serena configuration file not found at {config_file_path}, autogenerating...")
cls._generate_config_file(config_file_path)
# load the configuration
log.info(f"Loading Serena configuration from {config_file_path}")
try:
loaded_commented_yaml = load_yaml(config_file_path)
except Exception as e:
raise ValueError(f"Error loading Serena configuration from {config_file_path}: {e}") from e
# create the configuration instance
instance = cls(_loaded_commented_yaml=loaded_commented_yaml, _config_file_path=config_file_path)
num_migrations = 0
def get_value_or_default(field_name: str) -> Any:
nonlocal num_migrations
if field_name not in loaded_commented_yaml:
num_migrations += 1View on GitHub (pinned to 7fcbca7e62)
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.
Example fix
// before config = SerenaConfig.from_config_file() # FileNotFoundError on fresh machine // after config = SerenaConfig.from_config_file(generate_if_missing=True)
Defensive patterns
Strategy: try-catch
Validate before calling
from serena.config.serena_config import SerenaConfig path = SerenaConfig._determine_config_file_path() import os config_missing = not os.path.exists(path)
Type guard
def serena_config_exists() -> bool:
import os
from serena.config.serena_config import SerenaConfig
return os.path.exists(SerenaConfig._determine_config_file_path()) Try / catch
try:
config = SerenaConfig.from_config_file(generate_if_missing=False)
except FileNotFoundError:
config = SerenaConfig.from_config_file(generate_if_missing=True) Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Context file not found: {path.resolve()}
- Project configuration file not found: {yaml_path}
- Internal mode '{from_internal}' not found in {SERENAS_OWN_MO
- Internal context '{from_internal}' not found in {SERENAS_OWN
- Mode {name} not found in {SerenaPaths().user_modes_dir} or i
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/b0cf20846e054d86.
Report an issue: GitHub.