{"record":{"id":"4ef530fca75b75f6","repo":"rust-lang/cargo","slug":"more-than-one-of-hg-git-pijul-fossil-config","errorCode":null,"errorMessage":"more than one of .hg, .git, .pijul, .fossil configurations found and the ignore file can't be filled in as a result. specify --vcs to override detection","messagePattern":"more than one of \\.hg, \\.git, \\.pijul, \\.fossil configurations found and the ignore file can't be filled in as a result\\. specify --vcs to override detection","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_new.rs","lineNumber":530,"sourceCode":"        if path.join(\".hg\").exists() {\n            version_control = Some(VersionControl::Hg);\n            num_detected_vcses += 1;\n        }\n\n        if path.join(\".pijul\").exists() {\n            version_control = Some(VersionControl::Pijul);\n            num_detected_vcses += 1;\n        }\n\n        if path.join(\".fossil\").exists() {\n            version_control = Some(VersionControl::Fossil);\n            num_detected_vcses += 1;\n        }\n\n        // if none exists, maybe create git, like in `cargo new`\n\n        if num_detected_vcses > 1 {\n            anyhow::bail!(\n                \"more than one of .hg, .git, .pijul, .fossil configurations \\\n                 found and the ignore file can't be filled in as \\\n                 a result. specify --vcs to override detection\"\n            );\n        }\n    }\n\n    let mkopts = MkOptions {\n        version_control,\n        path,\n        name,\n        source_files: src_paths_types,\n        edition: opts.edition.as_deref(),\n        registry: opts.registry.as_deref(),\n    };\n\n    mk(gctx, &mkopts).with_context(|| {\n        format!(","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/ops/cargo_new.rs#L512-L548","documentation":"When `cargo init` does NOT receive an explicit `--vcs`, it auto-detects existing VCS metadata by probing for `.git`, `.hg`, `.pijul`, and `.fossil` directories. If MORE than one is present, cargo cannot decide which VCS's ignore-file conventions to extend (e.g. which `.gitignore` vs `.hgignore` to write), so it aborts and asks the user to disambiguate via `--vcs`.","triggerScenarios":"`cargo init` (no `--vcs`) in a directory whose ancestor tree contains two or more of `.git`, `.hg`, `.pijul`, `.fossil`. E.g. a repo that was migrated from Mercurial to Git but left a stale `.hg`, or a directory with both `.git` and `.fossil`.","commonSituations":"VCS migrations leaving leftover metadata. Nested repositories of different systems. Unusual monorepo setups mixing VCS tools. Cloning via one tool into a tree managed by another.","solutions":["Pass `--vcs` to override detection: `cargo init --vcs git` (or whichever you intend).","Remove the stale/unwanted VCS metadata directory (e.g. `rm -rf .hg`) so only one remains, then re-run `cargo init`.","Pass `--vcs none` to skip ignore-file generation entirely."],"exampleFix":"# before — directory has both .git and .hg\n$ cargo init   # error: more than one of .hg, .git, .pijul, .fossil\n\n# after\n$ cargo init --vcs git\n# or\n$ rm -rf .hg && cargo init","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn count_vcses(dir: &Path) -> usize {\n    [\".git\", \".hg\", \".pijul\", \".fossil\"].iter().filter(|d| dir.join(d).exists()).count()\n}\n// if count_vcses(&dir) > 1 { require explicit --vcs }","typeGuard":"fn has_unique_vcs(dir: &Path) -> bool { count_vcses(dir) == 1 }\nfn needs_explicit_vcs(dir: &Path) -> bool { count_vcses(dir) > 1 }","tryCatchPattern":null,"preventionTips":["Always pass `--vcs` when initializing inside trees with mixed VCS metadata.","Clean up stale VCS directories from prior migrations (e.g. remove old `.hg`).","In automation, probe for `.git`/`.hg`/`.pijul`/`.fossil` and decide `--vcs` explicitly."],"tags":["cargo-init","vcs","auto-detection","ignore-files"],"backgroundTag":null,"analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}