Skip to content

Fix/setup pi electron winstaller arm#690

Open
ceotjoe wants to merge 3 commits intoaccius:Stagingfrom
ceotjoe:fix/setup-pi-electron-winstaller-arm
Open

Fix/setup pi electron winstaller arm#690
ceotjoe wants to merge 3 commits intoaccius:Stagingfrom
ceotjoe:fix/setup-pi-electron-winstaller-arm

Conversation

@ceotjoe
Copy link
Contributor

@ceotjoe ceotjoe commented Mar 7, 2026

What does this PR do?

Fix setup-pi.sh failures on ARM / 32-bit Raspberry Pi OS

Problem

Three cascading failures were reported by users running setup-pi.sh on ARM hardware:

  1. electron-winstaller ENOENT on ARMnpm install --include=dev installs electron-builder, which pulls in electron-winstaller. Its postinstall script tries to copy vendor/7z-arm.exe → vendor/7z.exe. This Windows-only file does not exist on Linux targets, causing a hard failure. npm v10's rollback-on-failure behaviour then removes node_modules entirely, leaving the install in a broken state. [BUG] setup-pi.sh fails at step "npm install" #682

  2. NodeSource rejects 32-bit ARM (armhf) — NodeSource dropped armhf support from Node.js 20 onwards. Running the NodeSource setup script on a 32-bit Raspberry Pi OS (Bookworm or Bullseye) produces:

    Error: Unsupported architecture: armhf. Only amd64, arm64 are supported.
    

    The script header claimed 32-bit support but never handled this case.

  3. Fragile download on weak Pi connections — The initial armhf fix piped curl directly into tar. A single dropped connection mid-download resulted in a corrupt/partial extraction with no retry.


Changes

scripts/setup-pi.sh

Fix 1 — Skip harmful postinstall lifecycle scripts during npm install

- npm install --include=dev
+ ELECTRON_SKIP_BINARY_DOWNLOAD=1 npm install --include=dev --ignore-scripts

--ignore-scripts prevents all lifecycle hooks from running during install, specifically blocking electron-winstaller's postinstall. This is safe on a Pi because:

  • npm run build (Vite) is an explicit call, unaffected by --ignore-scripts
  • Husky git-hooks (prepare) are irrelevant on a production kiosk
  • No other devDependency requires a postinstall to function

A npm prune --omit=dev step is added after the build to remove electron, electron-builder, and related tooling (~500 MB) from node_modules on the Pi.

Fix 2 — Install Node.js from nodejs.org on 32-bit ARM

install_nodejs() now detects architecture via dpkg --print-architecture before invoking NodeSource. On armhf, it falls back to the official nodejs.org armv7l tarball, which Node.js continues to publish for all LTS releases including v22:

nodejs.org/dist/latest-v22.x/node-v22.x.x-linux-armv7l.tar.gz

amd64 and arm64 continue to use NodeSource unchanged.

Fix 3 — Robust download with retry for the armv7l tarball

The ~40 MB tarball download is split into two discrete steps:

  1. curl downloads to a mktemp file with --retry 3 --retry-delay 5 --retry-connrefused
  2. tar extracts from the file after a confirmed successful download
  3. The temp file is cleaned up afterwards

Download and extraction failures are reported separately, making future diagnosis easier.


Tested against

Hardware OS Arch Mode
Raspberry Pi CM3 8GB Bullseye (6.1.21-v7+) armhf (32-bit) --kiosk
Raspberry Pi (generic) Bookworm (32-bit) armhf --kiosk

Related issues

  • electron-winstaller ENOENT on ARM — reported by CM3/Bullseye user
  • NodeSource armhf rejection — reported by Bookworm 32-bit user
  • curl | tar connection reset — follow-up from same Bookworm 32-bit user

ceotjoe and others added 3 commits March 6, 2026 21:23
… error

electron-winstaller's postinstall tries to copy vendor/7z-arm.exe on ARM
Linux, which fails because the file doesn't exist for Linux targets. Added
--ignore-scripts to npm install and ELECTRON_SKIP_BINARY_DOWNLOAD=1 to
prevent these Windows-only lifecycle hooks from running on Raspberry Pi.
Also added npm prune --omit=dev after build to reclaim ~500 MB of disk space.

Fixes: #<electron-winstaller ENOENT on Bullseye/ARM>

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
NodeSource dropped armhf support from Node.js 20 onwards, causing a hard
failure on 32-bit Raspberry Pi OS (Bookworm/Bullseye). The official
nodejs.org project still publishes armv7l tarballs for all LTS releases,
so detect armhf via dpkg --print-architecture and download directly from
nodejs.org/dist/latest-v22.x/ instead of using the NodeSource setup script.
amd64 and arm64 continue to use NodeSource as before.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Piping curl directly into tar gives no opportunity to retry on a dropped
connection, which is common when downloading the ~40 MB tarball over a
flaky Pi network link. Save to a temp file first with --retry 3 so curl
can re-attempt on transient failures, then extract separately so download
and extraction errors are reported distinctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ceotjoe ceotjoe marked this pull request as ready for review March 7, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant