{"record":{"id":"f4e9c24a7166325b","repo":"DioxusLabs/dioxus","slug":"destination-directory-already-exists","errorCode":null,"errorMessage":"Destination directory '{}' already exists","messagePattern":"Destination directory '(.+?)' already exists","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/cli/component.rs","lineNumber":652,"sourceCode":"    dest: &Path,\n    exclude: &[String],\n    behavior: ComponentExistsBehavior,\n) -> Result<bool> {\n    async fn read_dir_paths(src: &Path) -> Result<Vec<PathBuf>> {\n        let mut entries = tokio::fs::read_dir(src).await?;\n        let mut paths = vec![];\n        while let Some(entry) = entries.next_entry().await? {\n            paths.push(entry.path());\n        }\n        Ok(paths)\n    }\n\n    // If the directory already exists, return an error, return silently or overwrite it depending on the behavior\n    if dest.exists() {\n        match behavior {\n            // The default behavior is to return an error\n            ComponentExistsBehavior::Error => {\n                bail!(\"Destination directory '{}' already exists\", dest.display());\n            }\n            // For dependencies, we return early\n            ComponentExistsBehavior::Return => {\n                debug!(\n                    \"Destination directory '{}' already exists, returning early\",\n                    dest.display()\n                );\n                return Ok(false);\n            }\n            // If the force flag is set, we overwrite the existing component\n            ComponentExistsBehavior::Overwrite => {\n                debug!(\n                    \"Destination directory '{}' already exists, overwriting\",\n                    dest.display()\n                );\n                tokio::fs::remove_dir_all(dest).await?;\n            }\n        }","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/cli/src/cli/component.rs#L634-L670","documentation":"Destination guard in copy_component_files (called from add_component): before copying a component's files, the code checks whether the destination directory already exists and — unless the configured ComponentExistsBehavior says to overwrite or silently skip — bails. The input at fault is the destination path, which would clobber pre-existing project files.","triggerScenarios":"Thrown at packages/cli/src/cli/component.rs:652 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The destination directory already exists. Choose another name or remove the existing directory."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}