From 9927971a7fb0590dac50a647ee0d815680f78440 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Wed, 11 Dec 2024 15:19:05 -0500 Subject: [PATCH 1/3] Check more paths --- .../electron/main/requirements/index.ts | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/apps/studio/electron/main/requirements/index.ts b/apps/studio/electron/main/requirements/index.ts index ecda4cf7..5eb01c3b 100644 --- a/apps/studio/electron/main/requirements/index.ts +++ b/apps/studio/electron/main/requirements/index.ts @@ -13,7 +13,7 @@ export function checkSystemRequirements(): RequirementsResponse { function checkGitInstallation(): boolean { try { - execSync('git --version', { stdio: 'ignore' }); + execSync('git --version', { stdio: 'ignore', env: process.env }); return true; } catch (error) { console.error('Git check failed:', error); @@ -23,7 +23,36 @@ function checkGitInstallation(): boolean { function checkNodeInstallation(): boolean { try { - execSync('npm --version', { stdio: 'ignore' }); + // Try common locations for Node installations + const commonPaths = [ + // Default paths + process.env.PATH, + process.env.Path, + // NodeJS official installer paths + '/usr/local/bin', + '/usr/local/nodejs/bin', + 'C:\\Program Files\\nodejs', + 'C:\\Program Files (x86)\\nodejs', + + // Node version managers + + // Nvm + `${process.env.HOME}/.nvm/versions/node`, + // Fnm + `${process.env.HOME}/.fnm/node-versions`, + // N + `${process.env.N_PREFIX}/bin`, + '/usr/local/n/versions/node', + // Volta + `${process.env.VOLTA_HOME}/bin`, + `${process.env.HOME}/.volta/bin`, + // ASDF + `${process.env.HOME}/.asdf/installs/nodejs`, + ] + .filter(Boolean) + .join(process.platform === 'win32' ? ';' : ':'); + + execSync('npm --version', { stdio: 'ignore', env: { ...process.env, PATH: commonPaths } }); return true; } catch (error) { console.error('Npm check failed:', error); From 246df222ddc300bae3c25f8c37f44a6e102f1b43 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Wed, 11 Dec 2024 15:30:06 -0500 Subject: [PATCH 2/3] Make sure paths are added --- .../electron/main/requirements/index.ts | 43 +++++++------------ 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/apps/studio/electron/main/requirements/index.ts b/apps/studio/electron/main/requirements/index.ts index 5eb01c3b..fa74b98b 100644 --- a/apps/studio/electron/main/requirements/index.ts +++ b/apps/studio/electron/main/requirements/index.ts @@ -23,36 +23,23 @@ function checkGitInstallation(): boolean { function checkNodeInstallation(): boolean { try { - // Try common locations for Node installations - const commonPaths = [ - // Default paths - process.env.PATH, - process.env.Path, - // NodeJS official installer paths - '/usr/local/bin', - '/usr/local/nodejs/bin', - 'C:\\Program Files\\nodejs', - 'C:\\Program Files (x86)\\nodejs', - - // Node version managers - - // Nvm - `${process.env.HOME}/.nvm/versions/node`, - // Fnm - `${process.env.HOME}/.fnm/node-versions`, - // N - `${process.env.N_PREFIX}/bin`, - '/usr/local/n/versions/node', - // Volta - `${process.env.VOLTA_HOME}/bin`, - `${process.env.HOME}/.volta/bin`, - // ASDF - `${process.env.HOME}/.asdf/installs/nodejs`, + const additionalNodePaths = [ + `${process.env.HOME}/.nvm/versions/node`, // Nvm + `${process.env.HOME}/.fnm/node-versions`, // Fnm + `${process.env.N_PREFIX}/bin`, // N + '/usr/local/n/versions/node', // N + `${process.env.VOLTA_HOME}/bin`, // Volta + `${process.env.HOME}/.volta/bin`, // Volta + `${process.env.HOME}/.asdf/installs/nodejs`, // ASDF ] - .filter(Boolean) - .join(process.platform === 'win32' ? ';' : ':'); + .filter(Boolean); + + // Combine existing PATH with additional paths + const existingPath = process.env.PATH || ''; + const pathSeparator = process.platform === 'win32' ? ';' : ':'; + const enhancedPath = [...additionalNodePaths, existingPath].join(pathSeparator); - execSync('npm --version', { stdio: 'ignore', env: { ...process.env, PATH: commonPaths } }); + execSync('npm --version', { stdio: 'ignore', env: { ...process.env, PATH: enhancedPath } }); return true; } catch (error) { console.error('Npm check failed:', error); From ec02e6c4494e8adf98ea5f0f7de48012bf941873 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Wed, 11 Dec 2024 15:31:23 -0500 Subject: [PATCH 3/3] Make sure paths are added --- apps/studio/electron/main/requirements/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/studio/electron/main/requirements/index.ts b/apps/studio/electron/main/requirements/index.ts index fa74b98b..b9f2234c 100644 --- a/apps/studio/electron/main/requirements/index.ts +++ b/apps/studio/electron/main/requirements/index.ts @@ -13,7 +13,7 @@ export function checkSystemRequirements(): RequirementsResponse { function checkGitInstallation(): boolean { try { - execSync('git --version', { stdio: 'ignore', env: process.env }); + execSync('git --version', { stdio: 'ignore' }); return true; } catch (error) { console.error('Git check failed:', error); @@ -23,7 +23,7 @@ function checkGitInstallation(): boolean { function checkNodeInstallation(): boolean { try { - const additionalNodePaths = [ + const versionManagerPaths = [ `${process.env.HOME}/.nvm/versions/node`, // Nvm `${process.env.HOME}/.fnm/node-versions`, // Fnm `${process.env.N_PREFIX}/bin`, // N @@ -34,10 +34,9 @@ function checkNodeInstallation(): boolean { ] .filter(Boolean); - // Combine existing PATH with additional paths const existingPath = process.env.PATH || ''; const pathSeparator = process.platform === 'win32' ? ';' : ':'; - const enhancedPath = [...additionalNodePaths, existingPath].join(pathSeparator); + const enhancedPath = [...versionManagerPaths, existingPath].join(pathSeparator); execSync('npm --version', { stdio: 'ignore', env: { ...process.env, PATH: enhancedPath } }); return true;