Skip to content

Commit

Permalink
fix: autoinstalling on mise x when the tool is in the config (#2816)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Oct 25, 2024
1 parent 1b6881b commit ac199e7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,12 @@ editLink: false
| typos | [asdf:aschiavon91/asdf-typos](https://github.com/aschiavon91/asdf-typos) |
| typst | [asdf:stephane-klein/asdf-typst](https://github.com/stephane-klein/asdf-typst) |
| uaa-cli | [asdf:vmware-tanzu/tanzu-plug-in-for-asdf](https://github.com/vmware-tanzu/tanzu-plug-in-for-asdf) |
| ubi | [ubi:houseabsolute/ubi](https://github.com/houseabsolute/ubi) |
| unison | [asdf:susurri/asdf-unison](https://github.com/susurri/asdf-unison) |
| updatecli | [asdf:updatecli/asdf-updatecli](https://github.com/updatecli/asdf-updatecli) |
| upt | [asdf:ORCID/asdf-upt](https://github.com/ORCID/asdf-upt) |
| upx | [asdf:jimmidyson/asdf-upx](https://github.com/jimmidyson/asdf-upx) |
| usage | [asdf:jdx/mise-usage](https://github.com/jdx/mise-usage) |
| usage | [ubi:jdx/usage](https://github.com/jdx/usage) |
| usql | [asdf:itspngu/asdf-usql](https://github.com/itspngu/asdf-usql) |
| uv | [asdf:asdf-community/asdf-uv](https://github.com/asdf-community/asdf-uv) |
| v | [asdf:jthegedus/asdf-v](https://github.com/jthegedus/asdf-v) |
Expand Down
3 changes: 2 additions & 1 deletion registry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -745,11 +745,12 @@ tx = ["asdf:ORCID/asdf-transifex"]
typos = ["asdf:aschiavon91/asdf-typos"]
typst = ["asdf:stephane-klein/asdf-typst"]
uaa-cli = ["asdf:vmware-tanzu/tanzu-plug-in-for-asdf"]
ubi = ["ubi:houseabsolute/ubi"]
unison = ["asdf:susurri/asdf-unison"]
updatecli = ["asdf:updatecli/asdf-updatecli"]
upt = ["asdf:ORCID/asdf-upt"]
upx = ["asdf:jimmidyson/asdf-upx"]
usage = [{full = "asdf:jdx/mise-usage", trust = true}]
usage = ["ubi:jdx/usage", "asdf:jdx/mise-usage"]
usql = ["asdf:itspngu/asdf-usql"]
uv = ["asdf:asdf-community/asdf-uv"]
v = ["asdf:jthegedus/asdf-v"]
Expand Down
7 changes: 5 additions & 2 deletions src/backend/ubi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ impl Backend for UbiBackend {
fn install_version_impl(&self, ctx: &InstallContext) -> eyre::Result<()> {
let mut v = ctx.tv.version.to_string();

if let Err(_err) = github::get_release(self.name(), &ctx.tv.version) {
if let Err(err) = github::get_release(self.name(), &ctx.tv.version) {
// this can fail with a rate limit error or 404, either way, try prefixing and if it fails, try without the prefix
// if http::error_code(&err) == Some(404) {
debug!("no tag found for {}, try prefixing with 'v'", ctx.tv);
debug!(
"Failed to get release for {}, trying with 'v' prefix: {}",
ctx.tv, err
);
v = format!("v{v}");
// }
}
Expand Down
14 changes: 10 additions & 4 deletions src/toolset/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,18 @@ impl ToolsetBuilder {
// in .mise.toml

// determine if we already have some active version in config
let set_as_latest = !ts
let current_active = ts
.list_current_requests()
.iter()
.any(|tvr| tvr.backend() == &arg.backend);
.into_iter()
.find(|tvr| tvr.backend() == &arg.backend);

if set_as_latest {
if let Some(current_active) = current_active {
// active version, so don't set "latest"
arg_ts.add_version(ToolRequest::new(
arg.backend.clone(),
&current_active.version(),
)?);
} else {
// no active version, so use "latest"
arg_ts.add_version(ToolRequest::new(arg.backend.clone(), "latest")?);
}
Expand Down

0 comments on commit ac199e7

Please sign in to comment.