The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): fresh Windows hosts can unpack Electron 40.10.3+ without the VC++ redist
ethernet8c3734f1d76a
diff --git a/hermes_cli/source_build.py b/hermes_cli/source_build.pyindex 286db75ae4c..c5c2ee3aa03 100644--- a/hermes_cli/source_build.py+++ b/hermes_cli/source_build.py@@ -39,6 +39,12 @@ def source_build_env(base_env: dict | None = None, *, explicit: bool = False, vepython = str(project_python(root)) if running_from_selected_environment(root) else sys.executableenv = {**os.environ, **(base_env or {}), "CI": "1", "HERMES_PYTHON": python,"PYTHON": python}+ # Electron's installer unpacks its binary with a native module that imports+ # VCRUNTIME140.dll, which a fresh Windows lacks. Our Python ships one, and+ # scripts/build/electron-runtime.mjs copies it beside that module.+ vc_runtime = Path(sys.base_prefix) / "vcruntime140.dll"+ if vc_runtime.is_file():+ env["HERMES_VC_RUNTIME"] = str(vc_runtime)env.pop("ESBUILD_BINARY_PATH", None)npmrc = get_hermes_home() / "npmrc"if npmrc.is_file():diff --git a/scripts/build/electron-runtime.mjs b/scripts/build/electron-runtime.mjsindex 7eb8e9db010..a5bfb7d86fc 100644--- a/scripts/build/electron-runtime.mjs+++ b/scripts/build/electron-runtime.mjs@@ -1,6 +1,7 @@#!/usr/bin/env nodeimport { execFileSync } from 'node:child_process'-import { existsSync, readFileSync, statSync } from 'node:fs'+import { copyFileSync, existsSync, readFileSync, statSync } from 'node:fs'+import { createRequire } from 'node:module'import { dirname, join, relative, resolve } from 'node:path'import { pathToFileURL } from 'node:url'import { parseArgs } from 'node:util'@@ -14,7 +15,7 @@ export function prepareElectronRuntime({ source, install = true, env = process.ejoin(source, 'node_modules/electron/package.json')].find(existsSync)if (!manifest) throw new Error('Missing prepared Electron dependency; install the locked desktop workspace first')const packageRoot = dirname(manifest)- const { version } = JSON.parse(readFileSync(manifest, 'utf8'))+ const { version, dependencies } = JSON.parse(readFileSync(manifest, 'utf8'))const desktop = JSON.parse(readFileSync(join(source, 'apps/desktop/package.json'), 'utf8'))const lock = JSON.parse(readFileSync(join(source, 'package-lock.json'), 'utf8'))const entry = lock.packages?.[relative(source, packageRoot).split('\\').join('/')]@@ -41,6 +42,14 @@ export function prepareElectronRuntime({ source, install = true, env = process.econst installerEnv = Object.fromEntries(Object.entries(env).filter(([key]) => !excluded.has(key.toLowerCase())))Object.assign(installerEnv, { ELECTRON_INSTALL_PLATFORM: process.platform, ELECTRON_INSTALL_ARCH: process.arch,npm_config_platform: process.platform, npm_config_arch: process.arch })+ // install.js unpacks with @electron-internal/extract-zip, whose Windows binding imports+ // VCRUNTIME140.dll. A fresh Windows has none, so the load fails (ERR_DLOPEN_FAILED).+ // Node loads bindings with LOAD_WITH_ALTERED_SEARCH_PATH, so a copy beside the binding+ // is found first. HERMES_VC_RUNTIME is the copy our Python ships.+ if (process.platform === 'win32' && env.HERMES_VC_RUNTIME && dependencies?.['@electron-internal/extract-zip']) {+ const binding = dirname(createRequire(manifest).resolve('@electron-internal/extract-zip'))+ copyFileSync(env.HERMES_VC_RUNTIME, join(binding, 'vcruntime140.dll'))+ }console.log(`electron-runtime: preparing locked Electron ${version} (${process.platform}-${process.arch})...`)execFileSync(process.execPath, [join(packageRoot, 'install.js')], { cwd: source, env: installerEnv, stdio: 'inherit' })if (!prepared()) throw new Error('Electron installer did not produce the prepared host runtime')