diff --git a/src/main/main.ts b/src/main/main.ts index f15c7b786d2ee725cf2f8779145f9a666b48fd15..3dd73fe879dbb43fc229e3d49e2959253f65e9c3 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -26,6 +26,7 @@ import { checkIfShellCommandExists, checkIfCondaEnvironmentExists, checkDependencies, + checkIfCondaBinExists, } from './util'; // //////////// @@ -90,7 +91,7 @@ ipcMain.handle('server:install_install-dependencies', async (event) => { }); ipcMain.handle('server:checkIfCondaExists', async (event) => { - const r = checkIfShellCommandExists('conda'); + const r = checkIfCondaBinExists(); console.log('conda exists', r); return r; }); @@ -101,10 +102,6 @@ ipcMain.handle('server:checkIfCondaEnvironmentExists', async (event) => { return envList; }); -ipcMain.handle('server:checkIfUvicornExists', async (event) => { - return checkIfShellCommandExists('uvicorn'); -}); - ipcMain.handle('server:checkDependencies', async (event) => { return await checkDependencies(); }); diff --git a/src/main/util.ts b/src/main/util.ts index 083208405bbfcccb409dbe689a68576ad7def73e..371eff19b65c2bd41312501732854a7bd8b9d00b 100644 --- a/src/main/util.ts +++ b/src/main/util.ts @@ -46,13 +46,11 @@ export function startLocalServer() { const options = { cwd: transformerLabDir, - // The following two options allow it to keep running after parent is closed - detached: true, stdio: ['ignore', out, err], shell: '/bin/bash', }; console.log('Starting local server at', mainFile); - localServer = spawn('bash', [mainFile], options); + localServer = spawn('bash', ['-l', mainFile], options); console.log('Local server started with pid', localServer.pid); @@ -140,16 +138,23 @@ export function checkIfShellCommandExists(command: string) { } } +export function checkIfCondaBinExists() { + // Look for the file ~/miniconda3/bin/conda + const condaBin = path.join(homeDir, 'miniconda3/bin/conda'); + if (fs.existsSync(condaBin)) { + return true; + } else { + return false; + } +} + export async function checkDependencies() { // First activate the transformerlab environment // Then run pip list // Then compare the output to the list of dependencies // If any are missing, return the missing ones // If all are present, manually check if the uvicorn command is present - const uvicornExists = checkIfShellCommandExists('uvicorn'); - - const command = - 'eval "$(conda shell.bash hook)" && conda activate transformerlab && pip list --format json'; + const command = '~/.transformerlab/src/install.sh list_installed_packages'; const options = { shell: '/bin/bash' }; const { stdout, stderr } = await awaitExec(command, options).catch((err) => { console.log('Error running pip list', err); @@ -187,11 +192,11 @@ export async function checkDependencies() { export async function checkIfCondaEnvironmentExists() { const options = { shell: '/bin/bash' }; console.log('Checking if Conda environment "transformerlab" exists'); - const { stdout, stderr } = await awaitExec(`conda env list`, options).catch( - (err) => { - console.log('Error running conda env list', err); - } - ); + const command = '~/.transformerlab/src/install.sh list_environments'; + + const { stdout, stderr } = await awaitExec(command, options).catch((err) => { + console.log('Error running conda env list', err); + }); if (stdout) console.log('stdout:', stdout); if (stderr) console.error('stderr:', stderr); diff --git a/src/renderer/components/Connect/LocalConnection.tsx b/src/renderer/components/Connect/LocalConnection.tsx index 999ba8167c037f73cac85f13c311bc1ecc19ed89..98991d20f39dc6d1628c655b5c7fd133d7f4d25b 100644 --- a/src/renderer/components/Connect/LocalConnection.tsx +++ b/src/renderer/components/Connect/LocalConnection.tsx @@ -745,7 +745,7 @@ function InstallStepper({ setServer }) { </InstallStep> <InstallStep thisStep={Steps.indexOf('CHECK_IF_CONDA_INSTALLED')} - title="Check if Conda is Installed" + title="Check if Conda is Installed at ~/miniconda3/" activeStep={activeStep} setActiveStep={setActiveStep} >