slint-ui/slint · error · CompileError
Could not compile
Error message
Could not compile {path} What it means
Raised by _load_file when the Slint compiler produced error-level diagnostics while compiling the given .slint file. The CompileError carries the full diagnostics list, so the actual parse/type errors are available on the exception.
Solutions
- Catch slint.CompileError and inspect e.diagnostics to see each error's line/column and message.
- Fix the reported .slint errors (syntax, unknown identifiers, type errors) in the referenced file.
- Check import paths and that all referenced components/globals exist and are exported.
- Validate the file with the slint-viewer or an editor with the Slint LSP before loading it at runtime.
Example fix
# before
module = slint.load_file("app.slint") # raises CompileError
# after
try:
module = slint.load_file("app.slint")
except slint.CompileError as e:
for d in e.diagnostics:
print(d.filename, d.line, d.column, d.message) Defensive patterns
Strategy: try-catch
Validate before calling
from pathlib import Path
assert Path("app.slint").exists(), "missing .slint file" Try / catch
try:
module = slint.load_file("app.slint")
except slint.CompileError as e:
for d in e.diagnostics:
print(f"{d.filename}:{d.line}:{d.column}: {d.message}")
raise Prevention
- Run the Slint compiler/viewer or LSP diagnostics on .slint files in CI before runtime.
- Never hand-edit .slint without checking diagnostics; inspect e.diagnostics for line numbers.
When it happens
Trigger: Calling slint.load_file(path) (directly or via load/compile APIs) on a .slint file containing syntax errors, unknown elements/properties, type errors, or missing imports.
Common situations: Typos in .slint markup; using features not enabled in the compiler version; referencing components or globals that don't exist; broken paths in imports; editing .slint files by hand without an LSP.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Callback ' ' in global ' ' cannot be used with a callback…
- Callback ' ' cannot be used with a callback decorator for…
- Callback ' ' cannot be used with a callback decorator for…
- Callback ' ' in global ' ' cannot be used with a callback…
- Cannot create component instance
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/8b717858e30003d1.
Report an issue: GitHub.
Appendix: source
Thrown at api/python/slint/slint/__init__.py:349
if translation_domain is not None:
compiler.translation_domain = translation_domain
result = compiler.build_from_path(Path(path))
diagnostics = result.diagnostics
if diagnostics:
if not quiet:
for diag in diagnostics:
if diag.level == native.DiagnosticLevel.Warning:
_logger.warning(diag)
if diag.level == native.DiagnosticLevel.Note:
_logger.debug(diag)
errors = [
diag for diag in diagnostics if diag.level == native.DiagnosticLevel.Error
]
if errors:
raise CompileError(f"Could not compile {path}", diagnostics)
module = types.SimpleNamespace()
for comp_name in result.component_names:
wrapper_class = _build_class(result.component(comp_name))
setattr(module, comp_name, wrapper_class)
structs, enums = result.structs_and_enums
for name, struct_prototype in structs.items():
name = _normalize_prop(name)
struct_wrapper = _build_struct(name, struct_prototype)
setattr(module, name, struct_wrapper)
for name, enum_class in enums.items():
name = _normalize_prop(name)
setattr(module, name, enum_class)
View on GitHub (pinned to bb937076de)