slint-ui/slint · error

SLINT_EMBED_RESOURCES has incorrect value. Must be either…

Error message

SLINT_EMBED_RESOURCES has incorrect value. Must be either unset, 'true' or 'false'

What it means

CompilerConfiguration::new parses the SLINT_EMBED_RESOURCES environment variable as a boolean; if it is set to anything other than 'true' or 'false', parse::<bool>() fails and the code panics. The variable controls whether all resources are embedded in the binary.

Solutions

  1. Set SLINT_EMBED_RESOURCES to exactly `true` or `false` (lowercase)
  2. Unset SLINT_EMBED_RESOURCES entirely if you want the default behavior
  3. Audit shell/CI profiles (e.g. .bashrc, CI config) for numeric or mixed-case boolean values

Example fix

// before
export SLINT_EMBED_RESOURCES=1
// after
export SLINT_EMBED_RESOURCES=true
Defensive patterns

Strategy: validation

Validate before calling

if let Some(v) = std::env::var("SLINT_EMBED_RESOURCES").ok() {
    assert!(matches!(v.as_str(), "true" | "false"), "SLINT_EMBED_RESOURCES must be 'true' or 'false', got {v:?}");
}

Prevention

When it happens

Trigger: Setting SLINT_EMBED_RESOURCES=1, =yes, =TRUE, or any value other than exactly 'true' or 'false' in the environment before running a program that creates a CompilerConfiguration.

Common situations: CI/exported environments where someone wrote SLINT_EMBED_RESOURCES=1 (Rust bool parsing only accepts lowercase 'true'/'false'); copy-pasted env setup from shell scripts.

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16). Data as JSON: /api/errors/befd6c1ae50dbaa6. Report an issue: GitHub.

Appendix: source

Thrown at internal/compiler/lib.rs:248

                .into_owned()
        });
        #[cfg(not(feature = "bundle-translations"))]
        return None;
    }

    pub fn new(output_format: OutputFormat) -> Self {
        let embed_resources = if std::env::var_os("SLINT_EMBED_TEXTURES").is_some()
            || std::env::var_os("DEP_MCU_BOARD_SUPPORT_MCU_EMBED_TEXTURES").is_some()
        {
            #[cfg(not(feature = "renderer-software"))]
            panic!(
                "the renderer-software feature must be enabled in i-slint-compiler when embedding textures"
            );
            #[cfg(feature = "renderer-software")]
            EmbedResourcesKind::EmbedTextures
        } else if let Ok(var) = std::env::var("SLINT_EMBED_RESOURCES") {
            let var = var.parse::<bool>().unwrap_or_else(|_|{
                panic!("SLINT_EMBED_RESOURCES has incorrect value. Must be either unset, 'true' or 'false'")
            });
            match var {
                true => EmbedResourcesKind::EmbedAllResources,
                false => EmbedResourcesKind::OnlyBuiltinResources,
            }
        } else {
            match output_format {
                #[cfg(feature = "rust")]
                OutputFormat::Rust => EmbedResourcesKind::EmbedAllResources,
                OutputFormat::Interpreter => EmbedResourcesKind::Nothing,
                _ => EmbedResourcesKind::OnlyBuiltinResources,
            }
        };

        let inline_all_elements = match std::env::var("SLINT_INLINING") {
            Ok(var) => var.parse::<bool>().unwrap_or_else(|_| {
                panic!(
                    "SLINT_INLINING has incorrect value. Must be either unset, 'true' or 'false'"

View on GitHub (pinned to 3a7e700487)