Skip to content

macOS x64 build crashes on launch: Could not load the "sharp" module #88

Description

@alpha5611331

Symptom

The macOS Intel (x64) build fails immediately on launch with a main-process dialog:

A JavaScript error occurred in the main process

Uncaught Exception:
Error: Could not load the "sharp" module using the darwin-x64 runtime
    at Object.<anonymous> (/Applications/Power Interview AI.app/Contents/Resources/
      app.asar/node_modules/sharp/lib/sharp.js:120:9)
    at Object.<anonymous> (.../app.asar/node_modules/sharp/lib/constructor.js:10:1)

Affects Power.Interview.AI-1.6.0.dmg / -mac.zip (x64). The app is unusable - sharp is
imported at startup by src/main/services/suggestion-action.service.ts, so the crash happens
before the window appears.

Root cause

Two independent packaging defects.

1. The darwin-x64 binary was never installed. pnpm 10+ materialises only the host
architecture's optional dependencies. release.yml builds on macos-latest, which is arm64,
but electron-builder --mac packages both architectures from that one node_modules. So
@img/sharp-darwin-x64 was never on disk and the x64 artifact shipped without it. The build
succeeds and uploads clean - nothing fails until a user launches it.

2. sharp was never unpacked from the asar. Its native .node locates libvips in a
sibling package through an @rpath (@loader_path/../../sharp-libvips-darwin-<arch>/lib),
and dlopen cannot read a dylib from inside an asar. This would have broken arm64 too; the
x64 build just failed earlier, at the require.

Why CI did not catch it

Nothing in the pipeline launches or inspects the packaged artifact. ci.yml runs lint, tsc,
the renderer build and test:main - all of which pass on a build that crashes on launch.

Additionally

.github/release_notes_template.md pointed every macOS user at the -arm64.dmg, so Intel
users were handed a build their machine cannot run at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions