{"record":{"id":"1448af868049b017","repo":"linera-io/linera-protocol","slug":"directory-already-exists","errorCode":null,"errorMessage":"Directory {} already exists","messagePattern":"Directory (.+?) already exists","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"linera-service/src/project.rs","lineNumber":37,"sourceCode":"    root: PathBuf,\n}\n\nimpl Project {\n    /// Creates a new application project from the template, scaffolding its files.\n    pub fn create_new(\n        name: &str,\n        linera_root: Option<&Path>,\n        dir: Option<PathBuf>,\n    ) -> Result<Self> {\n        ensure!(\n            !name.contains(std::path::is_separator),\n            \"Project name {name} should not contain path-separators\",\n        );\n        let root = match dir {\n            Some(dir) => dir,\n            None => {\n                let root = PathBuf::from(name);\n                ensure!(\n                    !root.exists(),\n                    \"Directory {} already exists\",\n                    root.display(),\n                );\n                root\n            }\n        };\n        ensure!(\n            root.extension().is_none(),\n            \"Project name {name} should not have a file extension\",\n        );\n        debug!(\"Creating directory at {}\", root.display());\n        fs_err::create_dir_all(&root)?;\n\n        debug!(\"Creating the source directory\");\n        let source_directory = Self::create_source_directory(&root)?;\n\n        debug!(\"Creating the tests directory\");","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-service/src/project.rs#L19-L55","documentation":"When create_new derives the target directory from the project name (no explicit dir given), it refuses to overwrite an existing directory, so scaffolding fails if ./<name> already exists on disk.","triggerScenarios":"Running `linera project new <name>` when a directory with that name already exists in the current working directory — e.g. running the scaffold twice.","commonSituations":"Retrying a failed scaffold without cleaning up; name collisions with pre-existing folders.","solutions":["Remove or rename the existing directory, then re-run the command","Choose a different project name","If supported by your flow, scaffold into an explicit empty directory instead"],"exampleFix":"# before\n$ ls\nmy-dapp/\n$ linera project new my-dapp\nerror: Directory my-dapp already exists\n\n# after\n$ mv my-dapp my-dapp-old\n$ linera project new my-dapp","handlingStrategy":"validation","validationCode":"let root = std::path::PathBuf::from(name);\nif root.exists() {\n    anyhow::bail!(\"directory {} already exists; remove it or pick another name\", root.display());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clean up after failed scaffolds before retrying","Pick distinctive project names in shared workspaces"],"tags":["cli","project","filesystem","scaffolding"],"backgroundTag":"directory-already-exists","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}