Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions e2e/backend/test_cargo_binstall
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ EOF

mise i
mise uninstall cargo:cargo-show cargo-binstall

###### TEST CUSTOM REGISTRY ######
export CARGO_REGISTRIES_OFFICIAL_GIT_INDEX=https://github.com/rust-lang/crates.io-index
export MISE_CARGO_REGISTRY_NAME=official_git
mise i
mise uninstall cargo:cargo-show cargo-binstall
4 changes: 4 additions & 0 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@
"default": true,
"description": "Use cargo-binstall instead of cargo install if available",
"type": "boolean"
},
"registry_name": {
"description": "Name of the cargo registry to use.",
"type": "string"
}
}
},
Expand Down
13 changes: 13 additions & 0 deletions settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ mise use -g cargo-binstall
```
"""

[cargo.registry_name]
env = "MISE_CARGO_REGISTRY_NAME"
type = "String"
optional = true
description = "Name of the cargo registry to use."
docs = """
Packages are installed from the official cargo registry.

You can set this to a different registry name if you have a custom feed or want to use a different source.

Please follow the [cargo alternative registries documentation](https://doc.rust-lang.org/cargo/reference/registries.html#using-an-alternate-registry) to configure your registry.
"""

[cargo_binstall]
type = "Bool"
hide = true
Expand Down
4 changes: 4 additions & 0 deletions src/backend/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl Backend for CargoBackend {
fn install_version_(&self, ctx: &InstallContext, tv: ToolVersion) -> eyre::Result<ToolVersion> {
let config = Config::try_get()?;
let install_arg = format!("{}@{}", self.tool_name(), tv.version);
let registry_name = &SETTINGS.cargo.registry_name;

let cmd = CmdLineRunner::new("cargo").arg("install");
let mut cmd = if let Some(url) = self.git_url() {
Expand Down Expand Up @@ -109,6 +110,9 @@ impl Backend for CargoBackend {
if let Some(c) = opts.get("crate") {
cmd = cmd.arg(c);
}
if let Some(registry_name) = registry_name {
cmd = cmd.arg(format!("--registry={registry_name}"));
}

cmd.arg("--root")
.arg(tv.install_path())
Expand Down