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
- 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.
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
- 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.
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
- Character at line is invalid. Cargo only supports UTF-8.
- cannot create package in the home directory help: use…
- cannot have a package with multiple libraries, found both
- `cargo init` cannot be run on existing Cargo packages help…
- files in the working directory contain changes that were…
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)