slint-ui/slint · error

No license file found in root LICENSES/ for SPDX id

Error message

No license file found in root LICENSES/ for SPDX id '{}'

What it means

check_licenses_dir maps the crate's SPDX license identifiers (from the license field) to files in the repository root LICENSES/ directory; it errors if an SPDX id has no matching license text file there.

Solutions

  1. Add the license text file to the root LICENSES/ directory named after the SPDX id (e.g. LICENSES/MIT.txt)
  2. Fix the SPDX id in the crate's license field if it was misspelled
  3. Verify how ids are matched to file stems in check_licenses_dir and follow the naming convention

Example fix

// before (Cargo.toml)
license = "MIT OR BSL-1.0"   // no LICENSES/BSL-1.0.txt exists
// after
license = "MIT OR Apache-2.0"  // or add LICENSES/BSL-1.0.txt
Defensive patterns

Strategy: validation

Validate before calling

let license = "MIT OR Apache-2.0"; // from Cargo.toml
for id in license.split(" OR ") {
    let found = std::fs::read_dir("LICENSES")?
        .filter_map(Result::ok)
        .any(|e| e.path().file_stem().map_or(false, |s| s == id));
    assert!(found, "LICENSES/{id}.* missing");
}

Type guard

fn spdx_id_has_file(id: &str, dir: &std::path::Path) -> bool {
    std::fs::read_dir(dir).map_or(false, |rd| rd.filter_map(Result::ok)
        .any(|e| e.path().file_stem().map_or(false, |s| s == id)))
}

Prevention

When it happens

Trigger: A crate's Cargo.toml license field contains an SPDX id (split on OR) for which no file named <id>.* exists under root LICENSES/ — e.g. license = "MIT OR Apache-2.0" but LICENSES/ only has MIT.txt and Apache-2.0.txt, and the license uses a new id like LicenseRef-Slint-... without a corresponding file.

Common situations: Adding a new license expression to a crate without adding the license text to the central LICENSES/ directory; typo in an SPDX id.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at xtask/src/license_headers_check.rs:1078

            .filter_map(|e| {
                let path = e.path();
                let stem = path.file_stem()?.to_string_lossy().to_string();
                let filename = path.file_name()?.to_string_lossy().to_string();
                Some((stem, filename))
            })
            .collect();

        let spdx_ids: Vec<&str> =
            license.split(" OR ").flat_map(|s| s.split(" AND ")).map(|s| s.trim()).collect();

        let mut expected_filenames: Vec<String> = Vec::new();
        for id in &spdx_ids {
            let filename =
                root_license_files.iter().find(|(stem, _)| stem == id).map(|(_, f)| f.clone());
            match filename {
                Some(f) => expected_filenames.push(f),
                None => {
                    return Err(anyhow!(
                        "No license file found in root LICENSES/ for SPDX id '{}'",
                        id
                    ));
                }
            }
        }

        if !licenses_dir.exists() {
            if self.fix_it {
                eprintln!(
                    "Fixing up {:?} as instructed. Creating missing LICENSES directory.",
                    crate_dir
                );
                std::fs::create_dir(&licenses_dir)
                    .context("Failed to create LICENSES directory")?;
            } else {
                return Err(anyhow!(
                    "Missing LICENSES directory for published crate {:?}",

View on GitHub (pinned to 3a7e700487)