{"record":{"id":"16f6be910ce07121","repo":"mihomo-party-org/clash-party","slug":"failed-to-install-core-error-instanceof-error","errorCode":null,"errorMessage":"Failed to install core: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Failed to install core: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/main/utils/github.ts","lineNumber":280,"sourceCode":"          if (existsSync(stagingPath)) rmSync(stagingPath)\n        } catch {\n          // ignore\n        }\n        throw error\n      }\n    }\n\n    // 清理临时文件\n    log.debug(`Cleaning up temporary file ${tempZip}`)\n    cleanupTempFile(tempZip)\n\n    log.info(`Successfully installed mihomo core version ${version}`)\n  } catch (error) {\n    // 解压失败时下载的压缩包会一直留在内核目录里，每次重试再落一份\n    cleanupTempFile(join(mihomoCoreDir(), `temp-core.zip`))\n    cleanupTempFile(join(mihomoCoreDir(), `temp-core.gz`))\n    log.error('Failed to install mihomo core', error)\n    throw new Error(\n      `Failed to install core: ${error instanceof Error ? error.message : String(error)}`\n    )\n  }\n}\n","sourceCodeStart":262,"sourceCodeEnd":285,"githubUrl":"https://github.com/mihomo-party-org/clash-party/blob/911e090537acdf7c50bee1c3aebecc2ef119a8b5/src/main/utils/github.ts#L262-L285","documentation":"The top-level catch of installMihomoCore: any failure during download, platform mapping, or extraction is logged and rethrown as 'Failed to install core: <inner message>'. It also cleans up temp-core.zip/temp-core.gz so failed downloads don't accumulate in the core directory. This is the error surface callers (installSpecificMihomoCore) actually see; the inner message identifies the stage that failed.","triggerScenarios":"Any of: all download mirrors failing (errors 84), unsupported platform (85), exe missing from zip (86), gzip extraction failure, write-permission denial to mihomoCoreDir(), or disk full during extraction.","commonSituations":"Offline or firewalled machine with all mirrors blocked; read-only or permission-restricted core directory after an app update; interrupted download leaving a truncated archive; antivirus locking/deleting the extracted binary on Windows.","solutions":["Read the inner message after the colon to identify the stage: HTTP codes → network/mirror issue; 'Unsupported platform' → no release for your arch; 'Executable file not found' → archive layout change.","Fix network/proxy access to github.com or configure a working mirror, then retry the install.","Ensure the mihomo core directory is writable (check permissions/AV interference) and free disk space is available.","Manually place the correct mihomo binary in the core directory as a workaround, then restart the app.","Delete leftover temp-core.zip/temp-core.gz (the handler should already do this) and retry cleanly."],"exampleFix":"// before: opaque retry loop\nawait installSpecificMihomoCore(version)\n// after: handle the wrapped error distinctly\ntry {\n  await installSpecificMihomoCore(version)\n} catch (e) {\n  const msg = String(e)\n  if (msg.includes('Unsupported platform')) {\n    console.error('No mihomo build for this OS/arch; install manually.')\n  } else if (/HTTP \\d+/.test(msg)) {\n    await retryWithBackoff(() => installSpecificMihomoCore(version))\n  } else {\n    throw e\n  }\n}","handlingStrategy":"try-catch","validationCode":"import { accessSync, constants } from 'fs'\n// preflight: core dir writable and enough disk space before attempting install\ntry {\n  accessSync(mihomoCoreDir(), constants.W_OK)\n} catch {\n  throw new Error(`Core directory not writable: ${mihomoCoreDir()}`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await installSpecificMihomoCore(version)\n} catch (e) {\n  const inner = String(e).replace(/^Failed to install core: /, '')\n  if (/HTTP \\d+/.test(inner)) retryLater() // network/mirror stage\n  else if (inner.includes('Unsupported platform')) showManualInstallGuide()\n  else if (inner.includes('not found in zip')) reportUpstreamLayoutChange()\n  else showGenericInstallError(inner)\n}","preventionTips":["Ensure the mihomo core directory exists, is writable, and has free disk space before installs","Check antivirus exclusion for the core directory on Windows","Keep app single-instance so temp archives aren't contended","Clean stale temp-core.zip/temp-core.gz files before retrying installs","Surface the inner message, not just the wrapper, when logging user-facing diagnostics"],"tags":["installation","github-releases","download","extraction","wrapper-error"],"backgroundTag":"core-install-failed","analyzedSha":"911e090537acdf7c50bee1c3aebecc2ef119a8b5","analyzedAt":"2026-08-30T13:00:49.174Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}