Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Run failure: Could not load the "sharp" module using the linux-x64 runtime #55

@PACHAKUTlQ

Description

@PACHAKUTlQ

I installed latest bun on Arch linux, ran bun install and bun run build:linux. The build ran successfully:

$ bun run build:linux
$ electron-vite build && electron-builder --linux
vite v6.3.3 building SSR bundle for production...
✓ 676 modules transformed.
out/main/index.js  615.71 kB
✓ built in 1.09s
vite v6.3.3 building SSR bundle for production...
✓ 2 modules transformed.
out/preload/index.js  6.66 kB
✓ built in 14ms

♻️  Generating routes...
✅ Processed routes in 76ms
vite v6.3.3 building for production...
✓ 1450 modules transformed.
../../out/renderer/index.html                     0.70 kB
../../out/renderer/assets/logo-fkiku5em.png      27.61 kB
../../out/renderer/assets/index-BA6ZuCWh.css    106.70 kB
../../out/renderer/assets/index-CfukB__g.js   2,843.40 kB
✓ built in 2.79s
  • electron-builder  version=26.0.12 os=6.14.7-arch2-1
  • loaded configuration  file=/home/redacted/mox/electron-builder.yml
  • writing effective config  file=dist/builder-effective-config.yaml
  • skipped dependencies rebuild  reason=npmRebuild is set to false
  • packaging       platform=linux arch=x64 electron=35.2.1 appOutDir=dist/linux-unpacked
  • building        target=AppImage arch=x64 file=dist/mox-0.1.0.AppImage
  • building        target=snap arch=x64 file=dist/mox_0.1.0_amd64.snap
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z size=1.6 MB parts=1
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/snap-template-4.0-2/snap-template-electron-4.0-2-amd64.tar.7z size=1.5 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/snap-template-4.0-2/snap-template-electron-4.0-2-amd64.tar.7z duration=22.469s
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z duration=23.612s
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z size=1.6 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z duration=48.266s
  • cannot move downloaded into final location (another process downloaded faster?)  path=/home/redacted/.cache/electron-builder/appimage/appimage-12.0.1
                                                                                     tempFile=/home/redacted/.cache/electron-builder/appimage/532984723
                                                                                     error=rename /home/redacted/.cache/electron-builder/appimage/532984723 /home/redacted/.cache/electron-builder/appimage/appimage-12.0.1: file exists
  • building        target=deb arch=x64 file=dist/mox_0.1.0_amd64.deb
  • adding autoupdate files for: deb. (Beta feature)  resourceDir=dist/linux-unpacked/resources
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86_64/fpm-1.9.3-2.3.1-linux-x86_64.7z size=5.0 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86_64/fpm-1.9.3-2.3.1-linux-x86_64.7z duration=48.795s

The build for both linux-unpacked and AppImage fails to run. Error:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: Could not load the "sharp" module using the linux-x64 runtime
ERR_DLOPEN_FAILED: libvips-cpp.so.8.16.1: cannot open shared object file: No such file or directory
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/home/redacted/mox/resources/app.asar/node_modules/sharp/lib/sharp.js:121:9)
    at Module._compile (node:internal/modules/cjs/loader:1562:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1715:10)
    at Module.load (node:internal/modules/cjs/loader:1296:32)
    at Module._load (node:internal/modules/cjs/loader:1115:12)
    at c._load (node:electron/js2c/node_init:2:17950)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:227:24)
    at Module.require (node:internal/modules/cjs/loader:1318:12)
    at require (node:internal/modules/helpers:136:16)

I tried to run bun install --cpu=x64 --os=linux sharp in the dist folder (and another time without those flags) and run mox again, still the same error.
I then tried to run bun install --cpu=x64 --os=linux sharp, bun install --cpu=x64 --os=linux, bun run build:linux in root dir of this repo, and ran the new mox build, still same error.

Adding sharp directory in asarUnpack as in electron-userland/electron-builder#6200 (comment) did not solve the issue either.
electron-builder.yml:

asarUnpack:
  - resources/**
  - node_modules/sharp/**

bun run dev opens the server successfully but still had the above issue.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions