cross-rs/cross · error
failed to get rustup version
Error message
failed to get rustup version
What it means
`version()` runs `rustup --version`, parses the first output line, and expects a semver token as the second whitespace-separated field. If the line is missing or has no version token, it bails with `failed to get rustup version`. This check exists to verify rustup is usable before operations like installing toolchains.
Solutions
- Install/update rustup: `rustup --version` manually must print e.g. `rustup 1.26.0 (...)`; if not, reinstall via rustup.rs.
- Ensure `rustup` is on PATH for the process (check PATH in CI/container environments).
- Update rustup (`rustup self update`) if the version line format differs from expectations.
- If rustup is present but crashing, repair the installation (`rustup toolchain install stable` or reinstall) — the failure usually precedes version parsing.
Example fix
// before
let v = rustup::version(msg_info)?; // bails if no version token
// after
let v = match rustup::version(msg_info) {
Ok(v) => v,
Err(e) => anyhow::bail!("rustup is missing or broken ({}). Install from https://rustup.rs", e),
}; Defensive patterns
Strategy: try-catch
Validate before calling
fn rustup_ok() -> bool {
std::process::Command::new("rustup").arg("--version")
.output().map(|o| o.status.success() && !o.stdout.is_empty()).unwrap_or(false)
} Try / catch
match rustup::version(msg_info) {
Ok(v) => v,
Err(e) => return Err(anyhow!("rustup missing or broken: {e}; install via https://rustup.rs")),
} Prevention
- Verify `rustup --version` prints a version line in the exact environment (CI image, container) before running tools.
- Keep rustup on PATH for the user/process running the command.
- Run `rustup self update` when version output formats drift.
When it happens
Trigger: `rustup --version` output contains no second field — e.g. rustup missing/aborting with only an error line, a wrapper script emitting custom text, or stderr/stdout capture returning empty output.
Common situations: rustup not installed or not on PATH (only an error line captured); extremely old or patched rustup builds with different `--version` output; broken rustup install where the binary exists but fails at startup (missing libgcc, corrupted toolchain); running inside images that shim rustup.
Related errors
- Refusing to push without tag or branch. Specify a…
- unexpected progress type: expected plain, auto, or tty and…
- invalid toolchain
- no rust-std component available for
- argument for --color must be auto, always, or never, but…
AI-assisted analysis of cross-rs/cross@8c1a8aa4b6 (2026-09-13).
Data as JSON: /api/errors/f1a771bebf85d0b9.
Report an issue: GitHub.
Appendix: source
Thrown at src/rustup.rs:177
installed,
not_installed,
})
}
fn version(msg_info: &mut MessageInfo) -> Result<Version> {
let out = rustup_command(msg_info, false)
.arg("--version")
.run_and_get_stdout(msg_info)?;
match out
.lines()
.next()
.and_then(|line| line.split_whitespace().nth(1))
{
Some(version) => {
semver::Version::parse(version).wrap_err_with(|| "failed to parse rustup version")
}
None => eyre::bail!("failed to get rustup version"),
}
}
pub fn install_toolchain(toolchain: &QualifiedToolchain, msg_info: &mut MessageInfo) -> Result<()> {
let mut command = rustup_command(msg_info, false);
let toolchain = toolchain.to_string();
command.args(["toolchain", "add", &toolchain, "--profile", "minimal"]);
if version(msg_info)? >= semver::Version::new(1, 25, 0) {
command.arg("--force-non-host");
}
command
.run(msg_info, false)
.wrap_err_with(|| format!("couldn't install toolchain `{toolchain}`"))
}
pub fn install(
target: &Target,
toolchain: &QualifiedToolchain,View on GitHub (pinned to 8c1a8aa4b6)