From 0c1e4fb140d96570fcc9e82166e8f07f6f9a80bb Mon Sep 17 00:00:00 2001
From: ali asaria <ali.asaria@gmail.com>
Date: Wed, 6 Mar 2024 20:14:49 -0500
Subject: [PATCH] fix 0.2.2 version of app to handle bash properly

---
 src/main/util.ts | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/main/util.ts b/src/main/util.ts
index 7ff3e0da..a1eeeb80 100644
--- a/src/main/util.ts
+++ b/src/main/util.ts
@@ -5,6 +5,7 @@ const fs = require('fs');
 const os = require('os');
 const { spawn, exec, ChildProcess } = require('child_process');
 const homeDir = os.homedir();
+const tranformerlabHomeDir = path.join(homeDir, '.transformerlab');
 const transformerLabDir = path.join(homeDir, '.transformerlab/src/');
 
 var localServer: typeof ChildProcess = null;
@@ -45,7 +46,7 @@ export function startLocalServer() {
     // The following two options allow it to keep running after parent is closed
     detached: true,
     stdio: ['ignore', out, err],
-    shell: true,
+    shell: '/bin/bash',
   };
   console.log('Starting local server at', mainFile);
   localServer = spawn('bash', [mainFile], options);
@@ -73,12 +74,12 @@ export function startLocalServer() {
         resolve({ status: 'success', code: code });
       } else {
         resolve({
-          status: 'error', code: code ,
-          message: 'May be fixed by running ~/.transformerlab/src/init.sh'
+          status: 'error',
+          code: code,
+          message: 'May be fixed by running ~/.transformerlab/src/init.sh',
         });
       }
     });
-
   });
 }
 
@@ -105,7 +106,11 @@ export function killLocalServer() {
 export function installLocalServer() {
   console.log('Installing local server');
 
-  const options = { shell: '/bin/sh' };
+  if (!fs.existsSync(tranformerlabHomeDir)) {
+    fs.mkdirSync(tranformerlabHomeDir);
+  }
+
+  const options = { shell: '/bin/sh', cwd: tranformerlabHomeDir };
   try {
     const child = exec(
       'curl https://raw.githubusercontent.com/transformerlab/transformerlab-api/main/download_and_install_remote_script.sh | sh',
-- 
GitLab