CherryHQ/cherry-studio · error · Error
Unsupported Linux packaging architecture: ${context.arch}
Error message
Unsupported Linux packaging architecture: ${context.arch} What it means
Thrown by scripts/before-pack.js (the electron-builder before-pack hook) when packaging for Linux on an architecture that is neither arm64 nor x64. The hook must select a GLIBC-compatible better-sqlite3 native artifact keyed by arch; only arm64 and x64 have verified artifacts. This fires earlier than the after-pack equivalent, before the native artifact is downloaded.
Source
Thrown at scripts/before-pack.js:118
throw new Error(
`Missing prebuilt packages for ${platform}-${arch}: ${missingPackages.join(', ')}\n` +
`Run \`rm -rf node_modules && pnpm install\` — pnpm only reads supportedArchitectures ` +
`on a fresh install, so plain \`pnpm install\` (even --force) will not fix it.`
)
}
}
exports.assertPrebuiltPackages = assertPrebuiltPackages
exports.default = async function (context) {
const arch = context.arch === Arch.arm64 ? 'arm64' : 'x64'
const platformName = context.packager.platform.name
const platform = platformToArch[platformName]
assertPrebuiltPackages(platform, arch)
if (platform === 'linux') {
const linuxArch = context.arch === Arch.arm64 ? 'arm64' : context.arch === Arch.x64 ? 'x64' : null
if (!linuxArch) throw new Error(`Unsupported Linux packaging architecture: ${context.arch}`)
const projectRoot = path.join(__dirname, '..')
const artifact = ensureLinuxNativeArtifact({ projectRoot, arch: linuxArch })
process.stdout.write(
`${artifact.cached ? 'Verified cached' : 'Downloaded'} GLIBC-compatible better-sqlite3 for ` +
`linux-${linuxArch} (${artifact.inspection.sha256})\n`
)
}
console.log(`Downloading bundled binaries for ${platform}-${arch}...`)
execSync(`node "${path.join(__dirname, 'download-binaries.js')}" ${platform} ${arch}`, { stdio: 'inherit' })
// Fail the build rather than ship a half-empty resources/binaries/<platform>.
require('./download-binaries').verifyBundledBinaries(platform, arch)
const excludePackages = async (packagesToExclude) => {
// 从项目根目录的 electron-builder.yml 读取 files 配置,避免多次覆盖配置导致出错
const electronBuilderConfigPath = path.join(__dirname, '..', 'electron-builder.yml')
const electronBuilderConfig = parse(fs.readFileSync(electronBuilderConfigPath, 'utf-8'))View on GitHub (pinned to 726446b54c)
Solutions
- Build Linux only for x64 and arm64 — the only arches with a verified GLIBC better-sqlite3 artifact.
- Remove the unsupported arch from electron-builder config / CI matrix.
- To support a new arch, first add and verify a better-sqlite3 artifact in scripts/linux-native/, then extend the arch ternary in both before-pack.js and after-pack.js.
- Verify the --arch value resolves to Arch.x64 or Arch.arm64 in the installed electron-builder version.
Example fix
// electron-builder.yml (before)
linux:
target:
- ia32
- x64
// after
linux:
target:
- x64
- arm64 Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_LINUX_ARCH = new Set(['x64', 'arm64'])
if (platform === 'linux' && !SUPPORTED_LINUX_ARCH.has(arch)) {
throw new Error(`Refusing to pack linux on unsupported arch '${arch}'`)
} Type guard
const isSupportedLinuxArch = (a: string): boolean => a === 'x64' || a === 'arm64'
Prevention
- Restrict Linux packaging to x64 and arm64.
- Provide a better-sqlite3 artifact before enabling any new arch.
- Validate arch in CI before the packaging step.
When it happens
Trigger: Running an electron-builder Linux target with --arch set to ia32, armv7l, or another unsupported value (e.g. npx electron-builder --linux --ia32). The context.arch is compared against Arch.arm64 and Arch.x64; anything else yields null.
Common situations: CI matrix with an unsupported Linux arch; a leftover ia32/armv7l target in the electron-builder config; upgrading electron-builder where Arch enum numeric values shifted; copy-pasting a build target without confirming native artifact availability.
Related errors
- Unsupported Linux packaging architecture: ${context.arch}
- Missing prebuilt packages for ${platform}-${arch}: ${missing
- [theme-contract] ${declaration.name} is defined twice in ${s
- [theme-contract] ${label} is missing root declarations: ${mi
- [theme-contract] ${label} references missing foundation vari
AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12).
Data as JSON: /api/errors/979151cf36a3df3e.
Report an issue: GitHub.