slint-ui/slint · error
Cannot create output directory
Error message
Cannot create output directory {out_class_dir:?} - {e} What it means
The android-activity backend build script fails when it cannot create the directory into which the compiled Java class files go (OUT_DIR plus the slint class path). Any create_dir_all error (permissions, a conflicting file, disk space) panics with this message and aborts the Android backend build.
Solutions
- Make the build output directory (OUT_DIR/target) writable by the build user
- Delete any non-directory file occupying the class output path and rebuild
- Free disk space if the error is ENOSPC
- Run `cargo clean -p slint-backend-android-activity` and rebuild
Example fix
// before: permission denied # chmod -R u+w target/ && cargo build // after build succeeds creating the class directory
Defensive patterns
Strategy: validation
Validate before calling
import os
out_class_dir = os.path.join(os.environ["OUT_DIR"], "slint")
assert os.access(os.path.dirname(out_class_dir), os.W_OK), "OUT_DIR not writable"
assert not os.path.isfile(out_class_dir), f"{out_class_dir} is a file, not a directory" Prevention
- Ensure CI runners grant write access to target/ and OUT_DIR
- Clean stale artifacts rather than hand-creating files under OUT_DIR
- Check disk space for Android builds
When it happens
Trigger: Building the android-activity crate where `std::fs::create_dir_all(&out_class_dir)` fails — read-only OUT_DIR, stale file at the class dir path, or ENOSPC.
Common situations: CI runners with restricted write permissions; a previous build left a file (not directory) at that path; disk quota exceeded during Android toolchain builds.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- Could not generate the java compiler command
- Could not run the java compiler
- Java compilation failed
- create
- write
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/3f5c87c887fb66c0.
Report an issue: GitHub.
Appendix: source
Thrown at internal/backends/android-activity/build.rs:32
}
let release_mode = env::var("PROFILE").as_ref().map(|s| s.as_str()) == Ok("release");
// This is the only Java source file
let java_src = "SlintAndroidJavaHelper.java";
let java_src_path = format!("java/{java_src}");
let slint_path: PathBuf = ["dev", "slint", "android-activity"].iter().collect();
let out_dir: PathBuf = env::var_os("OUT_DIR").unwrap().into();
let mut out_class_dir = out_dir.clone();
out_class_dir.push("java");
out_class_dir.push(slint_path);
if out_class_dir.try_exists().unwrap_or(false) {
let _ = std::fs::remove_dir_all(&out_class_dir);
}
std::fs::create_dir_all(&out_class_dir)
.unwrap_or_else(|e| panic!("Cannot create output directory {out_class_dir:?} - {e}"));
let android_jar = android_build::android_jar(None).expect("No Android platforms found");
// Compile the Java file into .class files
let o = JavaBuild::new()
.file(&java_src_path)
.class_path(&android_jar)
.classes_out_dir(&out_class_dir)
.java_source_version(8)
.java_target_version(8)
.debug_info(android_build::DebugInfo {
line_numbers: !release_mode,
variables: !release_mode,
source_files: !release_mode,
})
.command()
.unwrap_or_else(|e| panic!("Could not generate the java compiler command: {e}"))
.args(["-encoding", "UTF-8"])View on GitHub (pinned to bb937076de)