CherryHQ/cherry-studio · error · Error

Unsupported Linux packaging architecture: ${context.arch}

Error message

Unsupported Linux packaging architecture: ${context.arch}

What it means

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.

Source

Thrown at scripts/after-pack.js:14

const { Arch } = require('electron-builder')
const fs = require('fs')
const path = require('path')

const { readProjectBuildMetadata, replacePackagedBetterSqlite3 } = require('./linux-native/compat')

exports.default = async function (context) {
  const platform = context.packager.platform.name
  if (platform === 'windows') {
    fs.rmSync(path.join(context.appOutDir, 'LICENSE.electron.txt'), { force: true })
    fs.rmSync(path.join(context.appOutDir, 'LICENSES.chromium.html'), { force: true })
  } else if (platform === 'linux') {
    const arch = context.arch === Arch.arm64 ? 'arm64' : context.arch === Arch.x64 ? 'x64' : null
    if (!arch) throw new Error(`Unsupported Linux packaging architecture: ${context.arch}`)

    const projectRoot = path.join(__dirname, '..')
    const { destination, manifest } = replacePackagedBetterSqlite3({
      projectRoot,
      appOutDir: context.appOutDir,
      arch,
      metadata: readProjectBuildMetadata(projectRoot)
    })
    process.stdout.write(
      `Installed GLIBC-compatible better-sqlite3 for linux-${arch} at ${destination} ` +
        `(ABI ${manifest.electronAbi}, ${JSON.stringify(manifest.requirements)})\n`
    )
  }
}

View on GitHub (pinned to 726446b54c)

Solutions

  1. Restrict Linux builds to x64 and arm64 — these are the only arches with a verified GLIBC better-sqlite3 binary.
  2. Remove the unsupported arch target from your electron-builder config / CI matrix.
  3. 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.
  4. Confirm the --arch flag passed to electron-builder matches one of the supported Arch enum values.

Example fix

// before (CI matrix)
strategy:
  matrix:
    arch: [x64, arm64, armv7l] // armv7l triggers the error

// after
strategy:
  matrix:
    arch: [x64, arm64]
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking electron-builder for linux, assert the arch is supported
const SUPPORTED_LINUX_ARCH = new Set(['x64', 'arm64'])
if (!SUPPORTED_LINUX_ARCH.has(requestedArch)) {
  throw new Error(`Refusing to build: linux arch '${requestedArch}' has no better-sqlite3 artifact`)
}

Type guard

const isSupportedLinuxArch = (a: string): boolean => a === 'x64' || a === 'arm64'

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12). Data as JSON: /api/errors/cdc568885e5a5dee. Report an issue: GitHub.