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
- Use one of: `git`, `hg`, `pijul`, `fossil`, `none` — e.g. `cargo new --vcs git myproject`.
- Omit `--vcs` entirely to let cargo auto-detect (defaults to git for `new`, inherits existing for `init`).
- 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
- Validate the `--vcs` value against the five allowed strings before invoking cargo.
- When in doubt, omit `--vcs` and let cargo auto-detect.
- Trim whitespace and lowercase user-supplied VCS names in wrappers.
- Document the supported set wherever you expose a vcs option.
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
- can't specify both lib and binary outputs
- destination ` ` already exists Use `cargo init` to…
- unknown vcs specification
- can't find library ` `, rename file to `src/lib.rs` or…
- cannot create package in the home directory help: use…
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)