jdx/mise · error · eyre::Report
invalid Cargo crate name: {name:?}
Error message
invalid Cargo crate name: {name:?} What it means
get_crate_url() builds the crates.io sparse-index URL for a crate name so mise can list its versions. A crates.io index path can only be constructed from a non-empty, pure-ASCII name, so anything else (empty string or any non-ASCII character) is rejected with this bail before a URL is formed.
Source
Thrown at src/backend/cargo.rs:522
} else if let Some((user, repo)) = self.tool_name().split_once('/') {
format!("https://github.com/{user}/{repo}.git").parse().ok()
} else {
None
}
}
}
fn format_tool_options(options: &[&'static str]) -> String {
options
.iter()
.map(|option| format!("`{option}`"))
.collect::<Vec<_>>()
.join(", ")
}
fn get_crate_url(name: &str) -> eyre::Result<Url> {
if name.is_empty() || !name.is_ascii() {
bail!("invalid Cargo crate name: {name:?}");
}
let name = name.to_lowercase();
let url = match name.len() {
1 => format!("https://index.crates.io/1/{name}"),
2 => format!("https://index.crates.io/2/{name}"),
3 => format!("https://index.crates.io/3/{}/{name}", &name[..1]),
_ => format!(
"https://index.crates.io/{}/{}/{name}",
&name[..2],
&name[2..4]
),
};
Ok(url.parse()?)
}
fn parse_crate_versions(response: &str) -> eyre::Result<Vec<VersionInfo>> {
let mut versions = vec![];
for version in Deserializer::from_str(response).into_iter::<CrateVersion>() {View on GitHub (pinned to 6f52dcdf99)
Solutions
- Fix the crate name in mise.toml / CLI argument to the exact ASCII spelling from crates.io
- Check for invisible unicode characters (homoglyphs, NBSP) with a hex dump of the config line
- If generating config programmatically, validate the name is non-empty ASCII before writing it
Example fix
# before mise use "cargo:cargô" # after mise use cargo:cargo
Defensive patterns
Strategy: validation
Validate before calling
# shell: reject empty/non-ASCII crate names before calling mise
name='bat'
[[ "$name" =~ ^[A-Za-z0-9_-]+$ ]] && [[ -n "$name" ]] || { echo 'bad crate name'; exit 1; } Prevention
- Copy crate names verbatim from crates.io rather than typing them
- Lint generated mise.toml for empty or non-ASCII tool identifiers
- Sanitize names in scripts that build `cargo:<name>` strings
When it happens
Trigger: `mise use cargo:<name>` / a mise.toml entry `"cargo:<name>"` where <name> is empty or contains non-ASCII characters (e.g. a typo, a unicode look-alike character, or programmatic construction of a ToolRequest with a bad name). Fails during version listing or install when get_crate_url is called.
Common situations: Copy-pasting a crate name with a homoglyph or trailing unicode whitespace; an empty name from a templating/scripting bug in generated config; refactoring tool ids that accidentally drops the crate name after `cargo:`.
Related errors
- cargo-binstall cannot honor cargo install-only tool option(s
- windows_script_interpreter: {interpreter:?} must be a plain
- Windows script file name {filename:?} contains unsupported c
- workspace provider {provider_id:?} returned duplicate projec
- Cargo workspace member pattern {member:?} must be relative
AI-assisted analysis of jdx/mise@6f52dcdf99 (2026-08-22).
Data as JSON: /api/errors/d4d218878069d2e1.
Report an issue: GitHub.