From 4535ea6aaa5dcac647497c5cbe184ca702ff9be5 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 2 Sep 2025 13:23:12 -0400 Subject: [PATCH] refactor(loader): use the curl binary instead of `ureq` to download wasi-sdk --- crates/loader/Cargo.toml | 1 - crates/loader/src/loader.rs | 30 +++++++++++------------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/crates/loader/Cargo.toml b/crates/loader/Cargo.toml index bd44f87c..6e9e5760 100644 --- a/crates/loader/Cargo.toml +++ b/crates/loader/Cargo.toml @@ -44,7 +44,6 @@ serde_json.workspace = true tar.workspace = true tempfile.workspace = true url.workspace = true -ureq = "3.1.0" tree-sitter = { workspace = true } tree-sitter-highlight = { workspace = true, optional = true } diff --git a/crates/loader/src/loader.rs b/crates/loader/src/loader.rs index 44d62846..ee5b43c6 100644 --- a/crates/loader/src/loader.rs +++ b/crates/loader/src/loader.rs @@ -1179,28 +1179,20 @@ impl Loader { eprintln!("Downloading wasi-sdk from {sdk_url}..."); let temp_tar_path = cache_dir.join(sdk_filename); - let mut temp_file = fs::File::create(&temp_tar_path).with_context(|| { - format!( - "Failed to create temporary file at {}", - temp_tar_path.display() - ) - })?; - let response = ureq::get(&sdk_url) - .call() - .with_context(|| format!("Failed to download wasi-sdk from {sdk_url}"))?; - if !response.status().is_success() { - return Err(anyhow::anyhow!( - "Failed to download wasi-sdk from {}", - sdk_url - )); + let status = Command::new("curl") + .arg("-f") + .arg("-L") + .arg("-o") + .arg(&temp_tar_path) + .arg(&sdk_url) + .status() + .with_context(|| format!("Failed to execute curl for {sdk_url}"))?; + + if !status.success() { + return Err(anyhow!("Failed to download wasi-sdk from {sdk_url}",)); } - std::io::copy(&mut response.into_body().into_reader(), &mut temp_file) - .context("Failed to write to temporary file")?; - temp_file - .flush() - .context("Failed to flush downloaded file")?; eprintln!("Extracting wasi-sdk to {}...", wasi_sdk_dir.display()); self.extract_tar_gz_with_strip(&temp_tar_path, &wasi_sdk_dir) .context("Failed to extract wasi-sdk archive")?;