Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: in case of a version mismatch, fetch the correct version #687

Merged
merged 1 commit into from
Jan 29, 2024
Merged
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
27 changes: 19 additions & 8 deletions src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,29 @@ pub async fn get(
// consider system installed version

if let Some(required_version) = version {
// we have a version requirement
if required_version == detected_version {
tracing::info!(app = %app.name(), %detected_version, "using system installed binary");
// and a match, so return early
tracing::info!(app = %app.name(), %detected_version, "using system installed binary: {}", path.display());
return Ok(path);
} else if offline {
// a mismatch, in offline mode, we can't help here
bail!(
"couldn't find the required version ({required_version}) of the application {} (found: {detected_version})",
app.name(),
)
"couldn't find the required version ({required_version}) of the application {} (found: {detected_version}), unable to download in offline mode",
app.name(),
)
} else {
// a mismatch, so we need to download
tracing::info!(app = %app.name(), "tool version mismatch (required: {required_version}, system: {detected_version})");
}
}

return Ok(path);
}

if offline {
return Err(anyhow!("couldn't find application {}", &app.name()));
return Err(anyhow!(
"couldn't find application {}, unable to download in offline mode",
&app.name()
));
}

let cache_dir = cache_dir().await?;
Expand All @@ -292,10 +297,16 @@ pub async fn get(
.await?;
}

tracing::debug!(
"Using {} ({version}) from: {}",
app.name(),
bin_path.display()
);

Ok(bin_path)
}

/// Try to find a globally system installed version of the application.
/// Try to find a global system installed version of the application.
#[tracing::instrument(level = "trace")]
pub async fn find_system(app: Application) -> Option<(PathBuf, String)> {
let result = || async {
Expand Down
Loading