From 83bfa30d4bd5401d09fb02331f99ff0a04decb57 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 16 Jan 2025 12:04:43 -0800 Subject: [PATCH] server: improve abi/server change detection --- server/src/plugin/plugin-npm-dependencies.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/src/plugin/plugin-npm-dependencies.ts b/server/src/plugin/plugin-npm-dependencies.ts index 9fff9abda..ae30cee0c 100644 --- a/server/src/plugin/plugin-npm-dependencies.ts +++ b/server/src/plugin/plugin-npm-dependencies.ts @@ -4,7 +4,6 @@ import fs from 'fs'; import os from 'os'; import path from 'path'; import process from 'process'; -import semver from 'semver'; import { ensurePluginVolume } from "./plugin-volume"; export function defaultNpmExec(args: string[], options: child_process.SpawnOptions) { @@ -26,8 +25,16 @@ export function setNpmExecFunction(f: typeof npmExecFunction) { export function getPluginNodePath(name: string) { const pluginVolume = ensurePluginVolume(name); - const nodeMajorVersion = semver.parse(process.version).major; - let nodeVersionedDirectory = `node${nodeMajorVersion}-${process.platform}-${process.arch}`; + + const abi = process.versions.modules; + let runtime = process.env.npm_config_runtime; + if (!runtime && process.versions.electron) + runtime = 'electron'; + if (!runtime) + runtime = 'node'; + const { platform, arch } = process; + let nodeVersionedDirectory = `n-${runtime}-v${abi}-${platform}-${arch}`; + const scryptedBase = process.env.SCRYPTED_BASE_VERSION; if (scryptedBase) nodeVersionedDirectory += '-' + scryptedBase; @@ -98,7 +105,7 @@ export async function installOptionalDependencies(console: Console, packageJson: if (!de.isDirectory()) return; if (de.name.startsWith('linux') || de.name.startsWith('darwin') || de.name.startsWith('win32') - || de.name.startsWith('python') || de.name.startsWith('node')) { + || de.name.startsWith('python') || de.name.startsWith('node') || de.name.startsWith('n-')) { console.log('Removing old dependencies:', filePath); try { await fs.promises.rm(filePath, {