{"record":{"id":"4da570888663354c","repo":"abhigyanpatwari/GitNexus","slug":"could-not-install-the-embedding-runtime-err-instanceof-error","errorCode":null,"errorMessage":"Could not install the embedding runtime: ${err instanceof Error ? err.message : String(err)}\\n\\n${localEmbeddingStackMissingMessage()}","messagePattern":"Could not install the embedding runtime: (.+?)\\\\n\\\\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/embeddings-sync.ts","lineNumber":139,"sourceCode":"          'Run `gitnexus analyze --embeddings --force` to rebuild the column at the new width.',\n      );\n    }\n\n    if (!isHttpMode()) {\n      const assessment = assessLocalEmbeddingRuntime();\n      if (assessment.status === 'blocked' || assessment.status === 'prefix-unloadable') {\n        throw new Error(assessment.message);\n      }\n      if (assessment.status === 'needs-install') {\n        cliInfo(`Local embedding runtime is not installed.`);\n        cliInfo(`Downloading it now from your npm registry into ${getEmbeddingRuntimeDir()} …`);\n        try {\n          await installEmbeddingRuntime(\n            {},\n            getEmbeddingInstallTimeoutMs(ANALYZE_EMBEDDING_INSTALL_TIMEOUT_MS),\n          );\n        } catch (err) {\n          throw new Error(\n            `Could not install the embedding runtime: ${err instanceof Error ? err.message : String(err)}\\n\\n` +\n              localEmbeddingStackMissingMessage(),\n          );\n        }\n      }\n    }\n\n    await initLbug(lbugPath);\n    try {\n      const existing = await fetchExistingEmbeddingHashes(executeQuery);\n      let lastPercent = -1;\n\n      const countEmbeddings = async (): Promise<number | undefined> =>\n        persistedEmbeddingCountOrUndefined(await measurePersistedEmbeddingCount(executeQuery));\n      // One write path for every meta update this command makes. The re-read\n      // happens immediately before each save so a concurrent writer's fields\n      // survive. #2790 traced two production drifts to hand-copied writers of\n      // these exact fields, so this file keeps one copy instead of three.","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/cli/embeddings-sync.ts#L121-L157","documentation":"Thrown by embeddingsSyncCommand when the automatic on-demand installation of the local embedding runtime (onnxruntime-node / @huggingface/transformers into ~/.gitnexus/embedding-runtime) fails. The error wraps the underlying install failure message and appends actionable guidance (localEmbeddingStackMissingMessage) explaining how to enable local embeddings. It is a deliberate wrapper so users see a heal path instead of a raw npm/network error.","triggerScenarios":"Running `gitnexus embeddings sync` (or `analyze --embeddings`) when the local embedding stack is not installed and the call to installEmbeddingRuntime() rejects — e.g. npm registry unreachable, proxy misconfigured, GITNEXUS_EMBEDDING_RUNTIME_DIR unwritable, or the install times out (ANALYZE_EMBEDDING_INSTALL_TIMEOUT_MS).","commonSituations":"Fresh installs where the optional embedding stack was pruned from the default npm install; corporate proxies blocking the registry or NuGet download for CUDA; offline machines; a stale/partial ~/.gitnexus/embedding-runtime from a previous failed install.","solutions":["Check network/registry access, then rerun the command — the install is retried automatically on next sync.","Run `gitnexus embeddings install` manually and watch the full error output.","If behind a proxy, set GLOBAL_AGENT_HTTPS_PROXY (and npm registry config) before installing; add --cuda on CUDA hosts.","Point GITNEXUS_EMBEDDING_URL (with GITNEXUS_EMBEDDING_MODEL) at an OpenAI-compatible /v1/embeddings endpoint to skip the local runtime entirely.","If a leftover 1.6.12 install is present, do a clean reinstall of gitnexus (a --force refresh only updates prefix overrides)."],"exampleFix":"// before: sync fails in a sandboxed CI without registry access\nnpx gitnexus embeddings sync\n// after: embed over HTTP instead of installing the local runtime\nGITNEXUS_EMBEDDING_URL=https://api.example.com/v1 \\\nGITNEXUS_EMBEDDING_MODEL=text-embedding-3-small \\\nnpx gitnexus embeddings sync","handlingStrategy":"try-catch","validationCode":"// preflight before sync\nimport { assessLocalEmbeddingRuntime } from 'gitnexus/src/core/embeddings/runtime-support.js';\nconst a = assessLocalEmbeddingRuntime();\nif (a.status === 'needs-install') console.log('runtime will auto-install; ensure registry access');","typeGuard":null,"tryCatchPattern":"try {\n  await embeddingsSyncCommand(...);\n} catch (err) {\n  if (String(err.message).startsWith('Could not install the embedding runtime')) {\n    // fall back to HTTP embedding or instruct `gitnexus embeddings install`\n  }\n}","preventionTips":["Ensure npm registry and proxy env (GLOBAL_AGENT_HTTPS_PROXY) are configured before running sync","Run `gitnexus embeddings install` proactively after installing gitnexus","Use HTTP embedding (GITNEXUS_EMBEDDING_URL) in sandboxed/offline environments"],"tags":["embedding","installation","network","cli"],"backgroundTag":"missing-dependency","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}