{"record":{"id":"c4db7f75715de3b9","repo":"DioxusLabs/dioxus","slug":"failed-to-create-output-dir","errorCode":null,"errorMessage":"failed to create output dir","messagePattern":"failed to create output dir","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/wasm-split/wasm-split-cli/src/main.rs","lineNumber":46,"sourceCode":"\n#[derive(Parser)]\nstruct SplitArgs {\n    /// The wasm module emitted by rustc\n    original: PathBuf,\n\n    /// The wasm module emitted by wasm-bindgen\n    bindgened: PathBuf,\n\n    /// The output *directory* to write the split wasm files to\n    out_dir: PathBuf,\n}\n\nfn split(args: SplitArgs) {\n    let original = std::fs::read(&args.original).expect(\"failed to read input file\");\n    let bindgened = std::fs::read(&args.bindgened).expect(\"failed to read input file\");\n\n    _ = std::fs::remove_dir_all(&args.out_dir);\n    std::fs::create_dir_all(&args.out_dir).expect(\"failed to create output dir\");\n\n    tracing::info!(\"Building split module\");\n\n    let module = wasm_split_cli::Splitter::new(&original, &bindgened).unwrap();\n\n    let mut chunks = module.emit().unwrap();\n\n    // Write out the main module\n    tracing::info!(\n        \"Writing main module to {}\",\n        args.out_dir.join(\"main.wasm\").display()\n    );\n    std::fs::write(args.out_dir.join(\"main.wasm\"), &chunks.main.bytes).unwrap();\n\n    // Write the js module\n    std::fs::write(\n        args.out_dir.join(\"__wasm_split.js\"),\n        emit_js(&chunks.chunks, &chunks.modules),","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/wasm-split/wasm-split-cli/src/main.rs#L28-L64","documentation":"The wasm-split CLI's `split` subcommand deletes any existing directory at `out_dir` (ignoring errors) and then recreates it with `std::fs::create_dir_all(...).expect(\"failed to create output dir\")`. If the OS refuses to create the directory, the process panics with exit code 101 before any wasm work happens. This is an environment failure (permissions, disk, path collision), not a problem with the wasm binaries being split.","triggerScenarios":"Running `wasm-split-cli split <original> <bindgened> <out_dir>` where a regular file already occupies the out_dir path (remove_dir_all silently fails on files, so create_dir_all hits EEXIST/ENOTDIR); the parent directory is read-only or lacks write permission for the current user; the path is on a full disk, an unwritable mount, or exceeds filesystem path-length limits.","commonSituations":"CI containers running as non-root with a restricted workspace; passing `dist` as out_dir when `dist` already exists as a build artifact file; a relative out_dir resolved from an unexpected working directory when the binary is invoked by a script; Docker disk quota exhausted.","solutions":["Check whether a file (not a directory) occupies the out_dir path (`ls -la <out_dir>`) and remove or rename it","Verify the parent directory is writable (`chmod u+w` on the parent, or choose another location)","Pass an absolute out_dir path so the location does not depend on the invoker's cwd","Free disk space or raise the quota, then re-run the split command"],"exampleFix":"# before: dist exists as a file, split panics with \"failed to create output dir\"\nwasm-split-cli split app.wasm bg.wasm dist\n# after: clear the collision and use an absolute path\nrm -f dist && wasm-split-cli split app.wasm bg.wasm \"$(pwd)/dist\"","handlingStrategy":"validation","validationCode":"OUT_DIR=\"$(pwd)/dist\"\nif [ -e \"$OUT_DIR\" ] && [ ! -d \"$OUT_DIR\" ]; then echo \"out_dir exists and is not a directory\"; exit 1; fi\nmkdir -p \"$OUT_DIR\" 2>/dev/null || { echo \"cannot create out_dir\"; exit 1; }\n[ -w \"$OUT_DIR\" ] || { echo \"out_dir is not writable\"; exit 1; }\nwasm-split-cli split app.wasm bg.wasm \"$OUT_DIR\"","typeGuard":null,"tryCatchPattern":"if ! wasm-split-cli split app.wasm bg.wasm \"$OUT_DIR\"; then echo \"split failed (exit $?) - check the panic message for the OS error\" >&2; exit 1; fi","preventionTips":["Run the writable-directory pre-flight check above in CI before invoking wasm-split-cli","Always pass an absolute out_dir so cwd differences cannot redirect it","Never point out_dir at a path that may hold a build artifact file","Treat exit code 101 with this message as an environment failure - fix the path or permissions rather than re-running unchanged"],"tags":["wasm-split","cli","filesystem","permissions","io","panic"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}