{"record":{"id":"cdc568885e5a5dee","repo":"CherryHQ/cherry-studio","slug":"unsupported-linux-packaging-architecture-contex","errorCode":null,"errorMessage":"Unsupported Linux packaging architecture: ${context.arch}","messagePattern":"Unsupported Linux packaging architecture: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/after-pack.js","lineNumber":14,"sourceCode":"const { Arch } = require('electron-builder')\nconst fs = require('fs')\nconst path = require('path')\n\nconst { readProjectBuildMetadata, replacePackagedBetterSqlite3 } = require('./linux-native/compat')\n\nexports.default = async function (context) {\n  const platform = context.packager.platform.name\n  if (platform === 'windows') {\n    fs.rmSync(path.join(context.appOutDir, 'LICENSE.electron.txt'), { force: true })\n    fs.rmSync(path.join(context.appOutDir, 'LICENSES.chromium.html'), { force: true })\n  } else if (platform === 'linux') {\n    const arch = context.arch === Arch.arm64 ? 'arm64' : context.arch === Arch.x64 ? 'x64' : null\n    if (!arch) throw new Error(`Unsupported Linux packaging architecture: ${context.arch}`)\n\n    const projectRoot = path.join(__dirname, '..')\n    const { destination, manifest } = replacePackagedBetterSqlite3({\n      projectRoot,\n      appOutDir: context.appOutDir,\n      arch,\n      metadata: readProjectBuildMetadata(projectRoot)\n    })\n    process.stdout.write(\n      `Installed GLIBC-compatible better-sqlite3 for linux-${arch} at ${destination} ` +\n        `(ABI ${manifest.electronAbi}, ${JSON.stringify(manifest.requirements)})\\n`\n    )\n  }\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/scripts/after-pack.js#L1-L29","documentation":"Thrown by the electron-builder after-pack hook (scripts/after-pack.js) when packaging for Linux on an architecture that is neither arm64 nor x64. The hook swaps in a GLIBC-compatible better-sqlite3 native binary keyed by arch; only arm64 and x64 are supported because only those prebuilt artifacts are produced/verified.","triggerScenarios":"Running an electron-builder Linux target with --arch set to ia32, armv7l, or another value (e.g. npx electron-builder --linux --armv7l, or a CI matrix entry with arch: armv7l). The Arch enum from electron-builder is compared against Arch.arm64 and Arch.x64; anything else yields null and throws.","commonSituations":"Adding a new Linux arch to a release workflow without providing the matching better-sqlite3 artifact; a CI matrix typo; trying to build 32-bit Linux (ia32) which was never provisioned; upgrading electron-builder which changed Arch enum values.","solutions":["Restrict Linux builds to x64 and arm64 — these are the only arches with a verified GLIBC better-sqlite3 binary.","Remove the unsupported arch target from your electron-builder config / CI matrix.","If you genuinely need a new arch, first add and verify a better-sqlite3 native artifact for it in scripts/linux-native/, then extend the ternary in after-pack.js and before-pack.js.","Confirm the --arch flag passed to electron-builder matches one of the supported Arch enum values."],"exampleFix":"// before (CI matrix)\nstrategy:\n  matrix:\n    arch: [x64, arm64, armv7l] // armv7l triggers the error\n\n// after\nstrategy:\n  matrix:\n    arch: [x64, arm64]","handlingStrategy":"validation","validationCode":"// Before invoking electron-builder for linux, assert the arch is supported\nconst SUPPORTED_LINUX_ARCH = new Set(['x64', 'arm64'])\nif (!SUPPORTED_LINUX_ARCH.has(requestedArch)) {\n  throw new Error(`Refusing to build: linux arch '${requestedArch}' has no better-sqlite3 artifact`)\n}","typeGuard":"const isSupportedLinuxArch = (a: string): boolean => a === 'x64' || a === 'arm64'","tryCatchPattern":null,"preventionTips":["Keep Linux build matrices restricted to x64 and arm64.","Add a native artifact for any new arch before enabling it in the build config.","Validate arch in CI before the electron-builder step so failures are clear and early."],"tags":["build","electron-builder","linux","packaging","native-modules"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}