Skip to content

Commit

Permalink
fix uvx (requires manual install)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kvadratni committed Feb 8, 2025
1 parent e23da13 commit 34d9b4d
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion ui/desktop/src/utils/binaryPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,43 @@ import path from 'node:path';
import fs from 'node:fs';
import Electron from 'electron';
import log from './logger';
import { execSync } from 'child_process';

const checkWindowsDependency = (dependency: string): boolean => {
try {
execSync(`where ${dependency}`, { stdio: 'ignore' });
return true;
} catch {
return false;
}
};

export const getBinaryPath = (app: Electron.App, binaryName: string): string => {
const isDev = process.env.NODE_ENV === 'development';
const isPackaged = app.isPackaged;
const isWindows = process.platform === 'win32';
const executableName = isWindows ? `${binaryName}.exe` : binaryName;

// List of possible paths to check
// Windows-specific handling
if (isWindows) {
const requiredDeps = ['npx', 'uvx'];
const missingDeps = requiredDeps.filter((dep) => !checkWindowsDependency(dep));

if (missingDeps.length > 0) {
const error = `Required dependencies not found on Windows: ${missingDeps.join(', ')}. Please install them manually.`;
log.error(error);
throw new Error(error);
}

// On Windows, if dependencies are installed, return the command name directly
// These will be resolved through PATH
if (binaryName === 'npx' || binaryName === 'uvx') {
log.info(`Using system-installed ${binaryName} on Windows`);
return binaryName;
}
}

// For non-Windows systems or other binaries, use the regular path resolution
const possiblePaths = [];

if (isDev && !isPackaged) {
Expand Down

0 comments on commit 34d9b4d

Please sign in to comment.