{"record":{"id":"e65b8460b5948c8e","repo":"linera-io/linera-protocol","slug":"failed-to-initialize-git-repository-at","errorCode":null,"errorMessage":"failed to initialize git repository at {}","messagePattern":"failed to initialize git repository at (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"linera-service/src/project.rs","lineNumber":159,"sourceCode":"    }\n\n    fn create_test_directory(project_root: &Path) -> Result<PathBuf> {\n        let test_directory = project_root.join(\"tests\");\n        fs_err::create_dir_all(&test_directory)?;\n        Ok(test_directory)\n    }\n\n    fn initialize_git_repository(project_root: &Path) -> Result<()> {\n        let output = Command::new(\"git\")\n            .args([\n                \"init\",\n                project_root\n                    .to_str()\n                    .context(\"project name contains non UTF-8 characters\")?,\n            ])\n            .output()?;\n\n        ensure!(\n            output.status.success(),\n            \"failed to initialize git repository at {}\",\n            project_root.display()\n        );\n\n        Self::write_string_to_file(&project_root.join(\".gitignore\"), \"/target\")\n    }\n\n    fn create_cargo_toml(\n        project_root: &Path,\n        project_name: &str,\n        linera_root: Option<&Path>,\n    ) -> Result<()> {\n        let toml_path = project_root.join(\"Cargo.toml\");\n        let (linera_sdk_dep, linera_sdk_dev_dep) = Self::linera_sdk_dependencies(linera_root);\n        let binary_root_name = project_name.replace('-', \"_\");\n        let contract_binary_name = format!(\"{binary_root_name}_contract\");\n        let service_binary_name = format!(\"{binary_root_name}_service\");","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-service/src/project.rs#L141-L177","documentation":"Project::initialize_git_repository shells out to `git init` for the freshly scaffolded project and fails when the command exits non-zero. The scaffold itself is complete; only the VCS initialization failed.","triggerScenarios":"Calling initialize_git_repository when git is absent from PATH, the project directory was removed mid-run, or filesystem permissions deny creating .git.","commonSituations":"Minimal Docker or CI images without git installed; read-only output directories; unusual global git templates or configs that make `git init` fail; safe.directory restrictions in containers.","solutions":["Verify git is installed and on PATH (`git --version`)","Check write permissions on the project directory and re-run `git init <path>` manually to see the real error","Install git in the image/environment (e.g. `apt-get install -y git`) and re-scaffold or init manually","Inspect global git config/templates if git init fails reproducibly"],"exampleFix":"# before (container without git)\n$ linera project new my-dapp\nerror: failed to initialize git repository at my-dapp\n\n# after\n$ apt-get install -y git\n$ linera project new my-dapp","handlingStrategy":"validation","validationCode":"let git_ok = std::process::Command::new(\"git\")\n    .arg(\"--version\")\n    .output()\n    .map(|o| o.status.success())\n    .unwrap_or(false);\nif !git_ok {\n    eprintln!(\"git not available -- skipping repository initialization\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install git in Docker/CI images used for scaffolding","Ensure the output directory is writable","Run `git init` manually afterwards if you intentionally ship without git"],"tags":["cli","project","git","scaffolding","environment"],"backgroundTag":"git-init-failed","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}