rust-lang/cargo · error

unknown vcs specification

Error message

unknown vcs specification: `{}`

What it means

`VersionControl::from_str` accepts exactly `git`, `hg`, `pijul`, `fossil`, and `none`. Any other string — passed via `cargo new --vcs <s>` or read from a config field deserialized into `VersionControl` — is rejected with the offending token echoed back.

Solutions

  1. Use one of: `git`, `hg`, `pijul`, `fossil`, `none` — e.g. `cargo new --vcs git myproject`.
  2. Omit `--vcs` entirely to let cargo auto-detect (defaults to git for `new`, inherits existing for `init`).
  3. Check for typos or trailing whitespace in the value, especially when read from config.

Example fix

# before
$ cargo new --vcs svn myproject   # error

# after
$ cargo new --vcs git myproject
# or
$ cargo new --vcs none myproject
Defensive patterns

Strategy: validation

Validate before calling

fn valid_vcs(s: &str) -> bool {
    matches!(s, "git" | "hg" | "pijul" | "fossil" | "none")
}
// if !valid_vcs(&v) { return error before calling cargo new --vcs }

Type guard

fn parse_vcs(s: &str) -> Option<&'static str> {
    match s { "git"=>Some("git"), "hg"=>Some("hg"), "pijul"=>Some("pijul"), "fossil"=>Some("fossil"), "none"=>Some("none"), _=>None }
}

Prevention

When it happens

Trigger: `cargo new --vcs svn myproject`, `cargo new --vcs cvs myproject`, or any `--vcs` value outside the five allowed. Also triggered when a config file/TOML field deserialized as `VersionControl` contains an unrecognized variant.

Common situations: Typing `--vcs github`, `--vcs git-hub`, `--vcs none` misspelled (`--vcs noone`). Copying a `vcs = "..."` value from docs that listed an unsupported VCS. Scripts that interpolate a variable VCS name.

Related errors


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

Appendix: source

Thrown at src/ops/cargo_new.rs:40

    pub kind: NewProjectKind,
    pub auto_detect_kind: bool,
    /// Absolute path to the directory for the new package
    pub path: PathBuf,
    pub name: Option<String>,
    pub edition: Option<String>,
    pub registry: Option<String>,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NewProjectKind {
    Bin,
    Lib,
}

impl NewProjectKind {
    fn is_bin(self) -> bool {
        self == NewProjectKind::Bin
    }
}

impl fmt::Display for NewProjectKind {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match *self {
            NewProjectKind::Bin => "binary (application)",
            NewProjectKind::Lib => "library",
        }
        .fmt(f)
    }
}

struct SourceFileInformation {
    relative_path: String,
    bin: bool,
}

struct MkOptions<'a> {

View on GitHub (pinned to 98a09e7e7d)