slint-ui/slint · error
create
Error message
create {}: {err} What it means
The Node.js binding build script fails when it cannot create the parent directory for a generated file (a Rust/JS language module). `write_if_changed` creates the target directory with `create_dir_all` before writing generated code, and panics with this message if the filesystem refuses. This is a build-time hard failure: the codegen cannot proceed without a writable output tree.
Solutions
- Check permissions on the build output directory (target/ and OUT_DIR) and make it writable by the build user
- If a regular file occupies the path where the directory should be, remove it and rebuild
- Free disk space / check quota if the filesystem reported ENOSPC
- Clean with `cargo clean` and rebuild to eliminate stale conflicting artifacts
Example fix
// before: build fails with EACCES // terminal: sudo chown -R $(whoami) target && cargo build // after # ensure OUT_DIR parent is writable before building chmod -R u+w target/
Defensive patterns
Strategy: validation
Validate before calling
const dir = path.dirname(outputFile);
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
fs.accessSync(path.dirname(outputFile), fs.constants.W_OK); Prevention
- Keep build output owned by the same non-root user that runs cargo
- Check disk space before long builds
- Avoid creating files that shadow expected generated directories
When it happens
Trigger: Running `cargo build` (or any build invoking api/node/build.rs) where `std::fs::create_dir_all` fails for the generated module's parent directory — e.g. OUT_DIR path is read-only, a file exists where a directory is expected, or disk is full.
Common situations: Read-only OUT_DIR after permission changes; a stale file named like the generated directory; running the build as a different user with restricted permissions; disk-full or quota-exceeded environments; paths exceeding filesystem limits.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- write
- Cannot create output directory
- a setter belongs to a field
- failed ( )
- Components written in Rust can not get embedded yet.
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/f421872b0323f77d.
Report an issue: GitHub.
Appendix: source
Thrown at api/node/build.rs:675
fn generated_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("typescript").join("generated")
}
/// The banner every generated module starts with. These files are gitignored, so REUSE
/// never sees them and they need no license header.
fn generated_header(sources: &[&str]) -> String {
format!(
"// AUTO-GENERATED by api/node/build.rs from {}. Do not edit.\n\n",
sources.join("\n// ")
)
}
/// Write `contents` only if it differs, so we don't invalidate downstream builds, and watch
/// the result so it regenerates when edited or removed by hand.
fn write_if_changed(path: &std::path::Path, contents: &str) {
println!("cargo:rerun-if-changed={}", path.display());
let dir = path.parent().expect("generated file has a parent directory");
std::fs::create_dir_all(dir).unwrap_or_else(|err| panic!("create {}: {err}", dir.display()));
let needs_write =
std::fs::read_to_string(path).map(|existing| existing != contents).unwrap_or(true);
if needs_write {
std::fs::write(path, contents)
.unwrap_or_else(|err| panic!("write {}: {err}", path.display()));
}
}
View on GitHub (pinned to bb937076de)