tauri-apps/tauri · error

failed to write checked_features file

Error message

failed to write checked_features file

What it means

In tauri's own build script, after determining the enabled Cargo features, the script writes the comma-joined feature list to `OUT_DIR/checked_features` (consumed by a unit test in src/lib.rs) and panics with this message if the write fails. A failure means the build output directory is not writable or missing.

Solutions

  1. Check the `target` directory is writable by the build user (fix ownership/permissions)
  2. Free disk space if the volume is full
  3. Remove unusual `--target-dir` overrides or give that directory write permissions
  4. Re-run the build after fixing the environment
Defensive patterns

Strategy: validation

Validate before calling

let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
assert!(out_dir.is_dir() && !out_dir.permissions().readonly(), "OUT_DIR must be writable");

Prevention

When it happens

Trigger: Building the `tauri` crate when `OUT_DIR` is missing, read-only, or the `checked_features` path cannot be created — e.g. restricted CI sandboxes, disk-full, or a nonstandard `--target-dir` with bad permissions.

Common situations: Docker/CI containers running cargo as a non-root user with read-only target dirs; read-only mounted target directories; full disks; Windows ACL/antivirus interference.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/81829fac4d6b2449. Report an issue: GitHub.

Appendix: source

Thrown at crates/tauri/build.rs:267

  let mut checked_features = Vec::new();
  let custom_protocol = has_feature(&mut checked_features, "custom-protocol");
  let dev = !custom_protocol;
  alias("custom_protocol", custom_protocol);
  alias("dev", dev);

  println!("cargo:dev={dev}");

  let target_os = std::env::var_os("CARGO_CFG_TARGET_OS").unwrap();
  let mobile = target_os == "ios" || target_os == "android";
  alias("desktop", !mobile);
  alias("mobile", mobile);

  let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());

  let checked_features_out_path = out_dir.join("checked_features");
  // file is used by a unit test in src/lib.rs to check that the features checked do exist in the Cargo.toml
  std::fs::write(checked_features_out_path, checked_features.join(","))
    .expect("failed to write checked_features file");

  // workaround needed to prevent `STATUS_ENTRYPOINT_NOT_FOUND` error in tests
  // see https://github.com/tauri-apps/tauri/pull/4383#issuecomment-1212221864
  let target_env = std::env::var_os("CARGO_CFG_TARGET_ENV");
  let is_tauri_workspace = std::env::var_os("__TAURI_WORKSPACE__").is_some_and(|v| v == "true");
  if is_tauri_workspace && target_os == "windows" && target_env.is_some_and(|trgt| trgt == "msvc") {
    embed_manifest_for_tests();
  }

  if target_os == "android" {
    fn env_var(var: &str) -> String {
      std::env::var(var).unwrap_or_else(|_| {
        panic!("`{var}` is not set, which is needed to generate the kotlin files for android.")
      })
    }

    if let Some(kotlin_out_dir) = std::env::var_os("WRY_ANDROID_KOTLIN_FILES_OUT_DIR") {
      let package = env_var("WRY_ANDROID_PACKAGE");

View on GitHub (pinned to 460ec35447)