helix-editor/helix · error
Could not load theme: {}
Error message
Could not load theme: {} What it means
`:theme <name>` asks Editor::theme_loader to find and parse a theme file (built-in themes or the user themes directory). A missing name or a TOML parse/theme-definition failure is wrapped as 'Could not load theme: <err>'. It runs on PromptEvent::Validate (when the prompt is submitted); preview-time load failures use a different path that shows the theme name instead.
Source
Thrown at helix-term/src/commands/typed.rs:1133
if args.is_empty() {
// Ensures that a preview theme gets cleaned up if the user backspaces until the prompt is empty.
cx.editor.unset_theme_preview()?;
} else if let Some(theme_name) = args.first() {
if let Ok(theme) = cx.editor.theme_loader.load(theme_name) {
if !(true_color || theme.is_16_color()) {
bail!("Unsupported theme: theme requires true color support");
}
cx.editor.set_theme_preview(theme)?;
};
};
}
PromptEvent::Validate => {
if let Some(theme_name) = args.first() {
let theme = cx
.editor
.theme_loader
.load(theme_name)
.map_err(|err| anyhow::anyhow!("Could not load theme: {}", err))?;
if !(true_color || theme.is_16_color()) {
bail!("Unsupported theme: theme requires true color support");
}
cx.editor.set_theme(theme)?;
} else {
let name = cx.editor.theme.name().to_string();
cx.editor.set_status(name);
}
}
};
Ok(())
}
fn yank_main_selection_to_clipboard(
cx: &mut compositor::Context,
_args: Args,View on GitHub (pinned to 079a789e8c)
Solutions
- Retry with a known-good built-in name (e.g. `:theme default`) to confirm the loader itself works.
- For custom themes, fix the TOML per the reported parse error and re-run `:theme <name>` — files are re-read on each invocation, no restart needed.
- Ensure the file lives in the user themes directory (~/.config/helix/themes/<name>.toml) and that `inherits` names an existing theme.
Defensive patterns
Strategy: try-catch
Validate before calling
// before switching, confirm the theme file exists where the loader looks
let p = user_themes_dir.join(format!("{name}.toml"));
if !p.exists() && !builtin_names.contains(name) { /* pick another name */ } Try / catch
match cx.editor.theme_loader.load(theme_name) {
Ok(theme) => cx.editor.set_theme_preview(theme)?,
Err(err) => cx.editor.set_error(format!("Could not load theme: {err}")), // keep current theme
} Prevention
- Validate custom themes by loading them once after every edit; errors surface immediately.
- Keep `inherits` parents present, and re-test themes after helix upgrades change theme keys.
When it happens
Trigger: `:theme nonexistent-name`; a custom theme in ~/.config/helix/themes with invalid TOML or invalid keys; `inherits = "..."` pointing at a theme that does not exist or itself fails to load.
Common situations: Typos in theme names; custom themes broken by helix upgrades that changed theme keys; themes whose inherit parent is missing; editing a theme file and re-selecting it.
Related errors
- Expected 'inherits' to be a string: {}
- Cycle found in inheriting: {}
- File not found for: {}
- Failed to load config: {}
- Command not provided
AI-assisted analysis of helix-editor/helix@079a789e8c (2026-08-16).
Data as JSON: /api/errors/b9d20463dd62e603.
Report an issue: GitHub.