gitbutlerapp/gitbutler · critical

Skill files were not properly embedded at build time…

Error message

Skill files were not properly embedded at build time. Please report this as a bug.

What it means

Skill file contents are embedded into the binary at build time (via include/embed mechanisms in SKILL_FILES). `write_skill_files` validates that none of the embedded contents are empty before writing, and bails with this internal-invariant error if they are, since writing empty skill files would silently produce a broken installation.

Solutions

  1. Rebuild `but` from a clean checkout (cargo clean && cargo build) so the skill files are embedded.
  2. Check the build script / embed configuration for the skill assets and fix paths.
  3. If it persists in an official build, report it as a bug per the message.
Defensive patterns

Strategy: try-catch

Validate before calling

// caller-side check before writing
if SKILL_FILES.iter().any(|f| f.content.is_empty()) { eprintln!("broken build: empty embedded skill files"); }

Try / catch

match write_skill_files(path, layout) {
    Err(e) if e.to_string().contains("not properly embedded") => eprintln!("rebuild the binary"),
    other => other?,
}

Prevention

When it happens

Trigger: Invoked from write_skill_files (freshness checks, installations, tests) when any entry in SKILL_FILES has an empty `content` field — i.e. a broken/incorrect build where the skill assets failed to be embedded.

Common situations: A locally built binary where the build script or include paths failed; using a development build without the VERSION/embed machinery; a packaging bug.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/21992a709de59832. Report an issue: GitHub.

Appendix: source

Thrown at crates/but/src/command/skill/mod.rs:1142

    let skill_content = std::str::from_utf8(SKILL_MD).context("SKILL.md is not valid UTF-8")?;
    std::str::from_utf8(CONCEPTS_MD).context("concepts.md is not valid UTF-8")?;
    std::str::from_utf8(EXAMPLES_MD).context("examples.md is not valid UTF-8")?;
    std::str::from_utf8(REFERENCE_MD).context("reference.md is not valid UTF-8")?;

    // Inject version into SKILL.md
    Ok(inject_version(skill_content, version))
}

/// Write the bundled skill files into `install_path`, creating the directory
/// structure as needed and injecting the CLI version into SKILL.md. An existing
/// stub stays a stub on every rewrite, so refreshes never upgrade a layout by
/// accident. Returns the version that was written.
pub(crate) fn write_skill_files(
    install_path: &std::path::Path,
    layout: SkillLayout,
) -> Result<&'static str> {
    if SKILL_FILES.iter().any(|f| f.content.is_empty()) {
        anyhow::bail!(
            "Skill files were not properly embedded at build time. Please report this as a bug."
        );
    }

    // Prepare all content before writing (validate UTF-8 and inject version)
    let version = option_env!("VERSION").unwrap_or("dev");
    let full_skill_md = prepare_skill_content(version)?;
    let layout = match installed_layout(&install_path.join("SKILL.md")) {
        SkillLayout::Stub => SkillLayout::Stub,
        SkillLayout::Full => layout,
    };
    let (skill_md_content, content_dir) = match layout {
        SkillLayout::Full => (full_skill_md, install_path.join("references")),
        SkillLayout::Stub => {
            let close = frontmatter_close(&full_skill_md)
                .context("SKILL.md has no frontmatter to build a stub from")?;
            let stub = format!(
                "{}stub: true\nallowed-tools: Bash(but skill:*)\n{}{STUB_MD}",

View on GitHub (pinned to 58e5313667)