rust-lang/cargo · error

more than one of .hg, .git, .pijul, .fossil configurations…

Error message

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

What it means

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`.

Solutions

  1. Pass `--vcs` to override detection: `cargo init --vcs git` (or whichever you intend).
  2. Remove the stale/unwanted VCS metadata directory (e.g. `rm -rf .hg`) so only one remains, then re-run `cargo init`.
  3. Pass `--vcs none` to skip ignore-file generation entirely.

Example fix

# before — directory has both .git and .hg
$ cargo init   # error: more than one of .hg, .git, .pijul, .fossil

# after
$ cargo init --vcs git
# or
$ rm -rf .hg && cargo init
Defensive patterns

Strategy: validation

Validate before calling

use std::path::Path;
fn count_vcses(dir: &Path) -> usize {
    [".git", ".hg", ".pijul", ".fossil"].iter().filter(|d| dir.join(d).exists()).count()
}
// if count_vcses(&dir) > 1 { require explicit --vcs }

Type guard

fn has_unique_vcs(dir: &Path) -> bool { count_vcses(dir) == 1 }
fn needs_explicit_vcs(dir: &Path) -> bool { count_vcses(dir) > 1 }

Prevention

When it happens

Trigger: `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`.

Common situations: 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.

Related errors


AI-assisted analysis of rust-lang/cargo@98a09e7e7d (2026-08-11). Data as JSON: /api/errors/4ef530fca75b75f6. Report an issue: GitHub.

Appendix: source

Thrown at src/ops/cargo_new.rs:530

        if path.join(".hg").exists() {
            version_control = Some(VersionControl::Hg);
            num_detected_vcses += 1;
        }

        if path.join(".pijul").exists() {
            version_control = Some(VersionControl::Pijul);
            num_detected_vcses += 1;
        }

        if path.join(".fossil").exists() {
            version_control = Some(VersionControl::Fossil);
            num_detected_vcses += 1;
        }

        // if none exists, maybe create git, like in `cargo new`

        if num_detected_vcses > 1 {
            anyhow::bail!(
                "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"
            );
        }
    }

    let mkopts = MkOptions {
        version_control,
        path,
        name,
        source_files: src_paths_types,
        edition: opts.edition.as_deref(),
        registry: opts.registry.as_deref(),
    };

    mk(gctx, &mkopts).with_context(|| {
        format!(

View on GitHub (pinned to 98a09e7e7d)