Skip to content

Visual Studio Code, rebuilt in Rust

Rust

fix(windows): find curl, openssl and the ripgrep binary on Windows

rokarturd893b078d660
diff --git a/native/crates/app/src/update.rs b/native/crates/app/src/update.rs
index 72489a746c6..05e9f540d3d 100644
--- a/native/crates/app/src/update.rs
+++ b/native/crates/app/src/update.rs
@@ -19,6 +19,8 @@ use serde_json::Value;
const FIRST_CHECK: Duration = Duration::from_secs(30);
const CHECK_INTERVAL: Duration = Duration::from_secs(60 * 60);
const PROGRESS_INTERVAL: Duration = Duration::from_millis(250);
+/// Windows 10 1803 and later ship curl.exe in System32.
+const CURL: &str = if cfg!(windows) { "curl" } else { "/usr/bin/curl" };
/// update.ts `State` of the darwin flow. Not reached on macOS: `Updating` (Windows), `Overwriting` and `Cancelling`.
#[derive(Clone, Debug, PartialEq)]
@@ -139,7 +141,7 @@ pub fn parse_feed(feed_url: &str, status: u16, body: &[u8], build: &Build) -> an
/// GETs the feed through curl (redirects followed, as a GitHub `releases/latest/download` URL needs): status and body.
pub fn fetch_feed(url: &str) -> anyhow::Result<(u16, Vec<u8>)> {
- let output = std::process::Command::new("/usr/bin/curl").args(["-sSL", "--max-time", "30", "-w", "\n%{http_code}", url]).output()?;
+ let output = std::process::Command::new(CURL).args(["-sSL", "--max-time", "30", "-w", "\n%{http_code}", url]).output()?;
if !output.status.success() {
bail!("{}", String::from_utf8_lossy(&output.stderr).trim());
}
@@ -492,7 +494,7 @@ async fn download_and_verify(this: &WeakEntity<UpdateService>, update: &Update,
let _ = std::fs::remove_dir_all(&staging);
std::fs::create_dir_all(&staging)?;
let (zip, headers) = (staging.join("update.zip"), staging.join("headers"));
- let mut curl = Command::new("/usr/bin/curl").args(["-fsSL", "--max-time", "3600", "-D"]).arg(&headers).arg("-o").arg(&zip).arg(&update.url).stdout(Stdio::null()).stderr(Stdio::piped()).spawn()?;
+ let mut curl = Command::new(CURL).args(["-fsSL", "--max-time", "3600", "-D"]).arg(&headers).arg("-o").arg(&zip).arg(&update.url).stdout(Stdio::null()).stderr(Stdio::piped()).spawn()?;
let status = loop {
cx.background_executor().timer(PROGRESS_INTERVAL).await;
if let Some(status) = curl.try_wait()? {
diff --git a/native/crates/exthost/src/request.rs b/native/crates/exthost/src/request.rs
index de63ec4a839..2e24fb723cc 100644
--- a/native/crates/exthost/src/request.rs
+++ b/native/crates/exthost/src/request.rs
@@ -260,7 +260,7 @@ mod tests {
let dir = std::env::temp_dir().join(format!("vsrustium-request-tls-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let openssl = |args: &[&str]| {
- let mut command = std::process::Command::new("/usr/bin/openssl");
+ let mut command = std::process::Command::new(if cfg!(windows) { "openssl" } else { "/usr/bin/openssl" });
command.args(args).current_dir(&dir).stderr(std::process::Stdio::null()).stdout(std::process::Stdio::null());
command
};
diff --git a/native/crates/search/src/ripgrep.rs b/native/crates/search/src/ripgrep.rs
index cab53a43f63..24583eeacec 100644
--- a/native/crates/search/src/ripgrep.rs
+++ b/native/crates/search/src/ripgrep.rs
@@ -16,7 +16,12 @@ pub fn rg_path(app_root: &Path) -> PathBuf {
"x86_64" => "x64",
other => other,
};
- app_root.join(format!("node_modules/@vscode/ripgrep-universal/bin/darwin-{arch}/rg"))
+ let (platform, binary) = match std::env::consts::OS {
+ "windows" => ("win32", "rg.exe"),
+ "linux" => ("linux", "rg"),
+ _ => ("darwin", "rg"),
+ };
+ app_root.join(format!("node_modules/@vscode/ripgrep-universal/bin/{platform}-{arch}/{binary}"))
}
/// The cancellation token of one search; cancelling kills the ripgrep it runs.