From 95107e2e695d184a3c312b658dc18e6f672b5972 Mon Sep 17 00:00:00 2001
From: ali asaria <aliasaria@users.noreply.github.com>
Date: Mon, 10 Feb 2025 14:01:25 -0500
Subject: [PATCH] check if curl is installed on the gui client machine (it is
 needed to download the API to the local machine)

---
 src/main/util.ts | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/main/util.ts b/src/main/util.ts
index 2e6ee3c1..04ccd244 100644
--- a/src/main/util.ts
+++ b/src/main/util.ts
@@ -242,6 +242,22 @@ export function killLocalServer() {
   });
 }
 
+export async function checkIfCurlInstalled() {
+  try {
+    const { stdout, stderr } = await awaitExec('curl --version');
+    if (stderr) {
+      console.error(`stderr: ${stderr}`);
+      return false;
+    }
+    console.log(`stdout: ${stdout}`);
+    return true;
+  }
+  catch (error) {
+    console.error(`Failed to check if curl is installed: ${error}`);
+    return false;
+  }
+}
+
 export async function installLocalServer() {
   console.log('Installing local server');
 
@@ -257,6 +273,14 @@ export async function installLocalServer() {
   // We can download the API in one line for linux/mac
   // but it's a little more complicated for windows, so call a bat file
   console.log('Platform:' + process.platform);
+
+  // First check if curl is installed on the client machine:
+  const curlInstalled = await checkIfCurlInstalled();
+  if (!curlInstalled) {
+    dialog.showMessageBox({message: 'Curl is not installed. Please install curl and try again.'});
+    return;
+  }
+
   const download_cmd = `curl https://raw.githubusercontent.com/transformerlab/transformerlab-api/main/install.sh | bash -s -- download_transformer_lab`;
   const installScriptCommand = isPlatformWindows()
     ? `wsl ` + download_cmd
-- 
GitLab