{"record":{"id":"b77ebdfeb18fbfda","repo":"louis-e/arnis","slug":"already-exists-and-was-not-created-by-arnis","errorCode":null,"errorMessage":"'{}' already exists and was not created by Arnis. Rename or move it, or choose a different Bedrock save path.","messagePattern":"'(.+?)' already exists and was not created by Arnis\\. Rename or move it, or choose a different Bedrock save path\\.","errorType":"error_code","errorClass":"BedrockSaveError","httpStatus":null,"severity":"error","filePath":"src/world_editor/bedrock.rs","lineNumber":219,"sourceCode":"        emit_gui_progress_update(92.0, \"Saving Bedrock world...\");\n        self.write_chunks_to_db(world)?;\n\n        emit_gui_progress_update(97.0, \"Saving Bedrock world...\");\n        self.write_metadata(world, xzbbox, llbbox)?;\n\n        emit_gui_progress_update(98.0, \"Saving Bedrock world...\");\n        self.package_mcworld()?;\n\n        emit_gui_progress_update(99.0, \"Saving Bedrock world...\");\n        self.cleanup_temp_dir()?;\n        Ok(())\n    }\n\n    /// Prepares the staging directory, reusing leftovers but never deleting foreign data.\n    fn prepare_output_dir(&self) -> Result<(), BedrockSaveError> {\n        if self.output_dir.exists() {\n            if !is_arnis_staging_dir(&self.output_dir) {\n                return Err(BedrockSaveError::Io(std::io::Error::new(\n                    std::io::ErrorKind::AlreadyExists,\n                    format!(\n                        \"'{}' already exists and was not created by Arnis. \\\n                         Rename or move it, or choose a different Bedrock save path.\",\n                        self.output_dir.display()\n                    ),\n                )));\n            }\n            fs::remove_dir_all(&self.output_dir)?;\n        }\n        if self.mcworld_path.exists() {\n            fs::remove_file(&self.mcworld_path)?;\n        }\n\n        fs::create_dir_all(&self.output_dir)?;\n        fs::write(self.output_dir.join(STAGING_MARKER), b\"\")?;\n        // db directory will be created by LevelDB\n        Ok(())","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/louis-e/arnis/blob/34048924d9365795fb0d832e76140a3fbdc413d9/src/world_editor/bedrock.rs#L201-L237","documentation":"When generating a Bedrock world, prepare_output_dir prepares the staging/output directory. If the directory already exists but is not recognized as an Arnis staging directory (is_arnis_staging_dir returns false), it refuses to touch it and returns BedrockSaveError::Io with ErrorKind::AlreadyExists and this message — protecting user data (a real save or unrelated folder) from being overwritten. Callers write_world and parallel_chunk_encode_writes_expected_records propagate this error.","triggerScenarios":"Calling write_world with an output_dir path that already exists on disk and was not created by Arnis — e.g. pointing at an existing Minecraft Bedrock save folder, an existing world you exported before with another tool, or any leftover directory lacking Arnis's staging marker.","commonSituations":"Choosing the same Bedrock save path as an existing world in the GUI; re-running generation after a partially deleted previous run where the Arnis marker file was removed; pointing output at a directory like Minecraft's com.mojang/minecraftWorlds/<existing world>; two generation runs racing on the same path.","solutions":["Pick a different output directory or rename the target path before generating","Manually move/rename or delete the existing directory if you are sure it is not needed (back up real saves first)","If the directory is a leftover from a crashed Arnis run whose marker was lost, move it aside manually — Arnis will never delete foreign-looking data itself","Check the path for typos (e.g. pointing at minecraftWorlds instead of a fresh folder)","Re-run generation after clearing the path; if it's a previous Arnis output you want to overwrite, remove the whole staging directory"],"exampleFix":"// before: output points at an existing world\noutput_dir = \"/home/user/.minecraft/com.mojang/minecraftWorlds/MyWorld\"\n// after: use a fresh, non-existent path\noutput_dir = \"/home/user/.minecraft/com.mojang/minecraftWorlds/arnis-city-2026-09-03\"","handlingStrategy":"validation","validationCode":"fn output_path_is_free(dir: &std::path::Path) -> Result<(), String> {\n    if dir.exists() {\n        Err(format!(\n            \"'{}' already exists — rename/move it or pick another Bedrock save path\",\n            dir.display()\n        ))\n    } else { Ok(()) }\n}\n// call before invoking write_world / generation","typeGuard":null,"tryCatchPattern":"match editor.write_world() {\n    Ok(()) => println!(\"World written\"),\n    Err(BedrockSaveError::Io(e)) if e.kind() == std::io::ErrorKind::AlreadyExists => {\n        eprintln!(\"Target exists and is not an Arnis staging dir: {e}\");\n        // prompt user for a different path, do not delete anything\n    }\n    Err(e) => eprintln!(\"Bedrock export failed: {e}\"),\n}","preventionTips":["Check output_dir.exists() in the UI before starting generation and ask for a new path","Never point output at an existing minecraftWorlds/<save> directory","Don't delete Arnis marker files from previous staging dirs if you want them reused","Back up real Bedrock saves before any export; Arnis will never delete foreign data for you","Use timestamped output directory names to avoid collisions between runs"],"tags":["filesystem","bedrock","directory-exists","rust","io"],"backgroundTag":"output-directory-already-exists","analyzedSha":"34048924d9365795fb0d832e76140a3fbdc413d9","analyzedAt":"2026-09-03T14:05:17.283Z","contentChangedAt":"2026-09-03T14:05:17.283Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}