Trying to build Etcher on Raspberry Pi 4

In a previous post, I actually did “npm i” not “npm io”, that was a typo.

This latest error seems to be an issue others have encountered before on the electron-builder repo [1] in the builder-util sub-package [2].

The error is:

Error: Unsupported arch arm
    at archFromString (/home/pi/Documents/etcher/node_modules/builder-util/src/arch.ts:43:13)
    at computeArchToTargetNamesMap (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/targets/targetFactory.ts:36:18)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:415:41
    at Generator.next (<anonymous>)

It’s being thrown in archFromString() [3], as called by computeArchToTargetNamesMap() [4].

More investigation needs to be done to determine where the string "arm" is coming from.

I’ll link this thread to a member of the device support team who may have more insight about how architectures report in the rpi4, or specifically on an rpi4 running BalenaOS.

[1] https://github.com/electron-userland/electron-builder/issues/4279
[2] https://github.com/electron-userland/electron-builder/tree/master/packages/builder-util
[3] https://github.com/electron-userland/electron-builder/blob/master/packages/builder-util/src/arch.ts#L43
[4] https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/src/targets/targetFactory.ts#L8

A few questions
a) What is the base image in which we are building this on the pi?
b) Can someone more familiar with node come up with a tiny node snippet that says the arch is ‘arm’

This is a Raspberry PI 4, with 4GB of memory.

It is running Raspbian Buster, upgraded to be current. To start from scratch, you would download " Raspbian Buster with desktop and recommended software" from here, and then do “sudo apt update && sudo apt upgrade”.

uname -a returns:

Linux pi4 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux

Is there anything more I can tell you?

@tinker2much you need to specify the architecture.
Could you please try with: ./node_modules/.bin/electron-builder --arm64 --linux deb.

@zvin, sorry for the delay. `then tried with specifying the arch:

pi@pi4:~/Documents/etcher $ ./node_modules/.bin/electron-builder --arm64 --linux deb
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
  • electron-builder version=20.40.2
  • loaded configuration file=/home/pi/Documents/etcher/electron-builder.yml
  • writing effective config file=dist/builder-effective-config.yaml
  • executing node-gyp rebuild arch=arm64
  • rebuilding native production dependencies platform=linux arch=arm64
  • packaging       platform=linux arch=arm64 electron=3.1.9 appOutDir=dist/linux-arm64-unpacked
  • downloading               parts=8 size=48 MB url=https://github.com/electron/electron/releases/download/v3.1.9/electron-v3.1.9-linux-arm64.zip
  • downloaded                duration=1m17.519s url=https://github.com/electron/electron/releases/download/v3.1.9/electron-v3.1.9-linux-arm64.zip
  • building        target=deb arch=arm64 file=dist/balena-etcher_1.5.60_arm64.deb
  • downloading               parts=1 size=4.6 MB url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86/fpm-1.9.3-2.3.1-linux-x86.7z
  • downloaded                duration=8.299s url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86/fpm-1.9.3-2.3.1-linux-x86.7z
Error: Exit code: 1. Command failed: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/fpm -s dir -t deb --architecture arm64 --name balena-etcher --force --after-install /tmp/t-ez5D68/0-after-install --after-remove /tmp/t-ez5D68/1-after-remove --description balenaEtcher is a powerful OS image flasher built with web technologies to ensure flashing an SDCard or USB drive is a pleasant and safe experience. It protects you from accidentally writing to your hard-drives, ensures every byte of data was written correctly and much more.
 Flash OS images to SD cards and USB drives, safely and easily. --version 1.5.60 --package /home/pi/Documents/etcher/dist/balena-etcher_1.5.60_arm64.deb --maintainer Balena Inc. <hello@etcher.io> --url https://github.com/balena-io/etcher --vendor Balena Inc. <hello@etcher.io> --category utils --deb-compression xz --deb-priority optional --depends gconf2 --depends gconf-service --depends libappindicator1 --depends libasound2 --depends libatk1.0-0 --depends libc6 --depends libcairo2 --depends libcups2 --depends libdbus-1-3 --depends libexpat1 --depends libfontconfig1 --depends libfreetype6 --depends libgcc1 --depends libgconf-2-4 --depends libgdk-pixbuf2.0-0 --depends libglib2.0-0 --depends libgtk-3-0 --depends liblzma5 --depends libnotify4 --depends libnspr4 --depends libnss3 --depends libpango1.0-0 --depends libstdc++6 --depends libx11-6 --depends libxcomposite1 --depends libxcursor1 --depends libxdamage1 --depends libxext6 --depends libxfixes3 --depends libxi6 --depends libxrandr2 --depends libxrender1 --depends libxss1 --depends libxtst6 --depends polkit-1-auth-agent | policykit-1-gnome | polkit-kde-1 --license Apache-2.0 /home/pi/Documents/etcher/dist/linux-arm64-unpacked/=/opt/balenaEtcher /home/pi/Documents/etcher/assets/iconset/16x16.png=/usr/share/icons/hicolor/16x16/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/32x32.png=/usr/share/icons/hicolor/32x32/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/48x48.png=/usr/share/icons/hicolor/48x48/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/128x128.png=/usr/share/icons/hicolor/128x128/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/256x256.png=/usr/share/icons/hicolor/256x256/apps/balena-etcher-electron.png /home/pi/Documents/etcher/assets/iconset/512x512.png=/usr/share/icons/hicolor/512x512/apps/balena-etcher-electron.png /tmp/t-ez5D68/2-balenaEtcher.desktop=/usr/share/applications/balena-etcher-electron.desktop
/home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: cannot execute binary file: Exec format error
/home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: Success

/home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: cannot execute binary file: Exec format error
/home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/pi/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: Success

    at /home/pi/Documents/etcher/node_modules/builder-util/src/util.ts:126:16
    at ChildProcess.exithandler (child_process.js:301:5)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:189:13)
    at Pipe._handle.close (net.js:600:12)
From previous event:
    at FpmTarget.build (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/targets/fpm.ts:93:44)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/platformPackager.ts:131:24
From previous event:
    at AsyncTaskManager.add (/home/pi/Documents/etcher/node_modules/builder-util/src/asyncTaskManager.ts:14:20)
    at LinuxPackager.packageInDistributableFormat (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/platformPackager.ts:123:17)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/platformPackager.ts:114:10
    at Generator.next (<anonymous>)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
From previous event:
    at LinuxPackager.pack (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/platformPackager.ts:111:95)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:430:24
    at Generator.next (<anonymous>)
    at xfs.stat (/home/pi/Documents/etcher/node_modules/fs-extra-p/node_modules/fs-extra/lib/mkdirs/mkdirs.js:56:16)
    at /home/pi/Documents/etcher/node_modules/graceful-fs/polyfills.js:285:20
    at FSReqWrap.oncomplete (fs.js:155:5)
From previous event:
    at Packager.doBuild (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:396:24)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:366:57
    at Generator.next (<anonymous>)
    at /home/pi/Documents/etcher/node_modules/graceful-fs/graceful-fs.js:111:16
    at /home/pi/Documents/etcher/node_modules/graceful-fs/graceful-fs.js:45:10
    at FSReqWrap.oncomplete (fs.js:141:20)
From previous event:
    at Packager._build (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:335:133)
    at /home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:331:23
    at Generator.next (<anonymous>)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
From previous event:
    at Packager.build (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/packager.ts:288:14)
    at build (/home/pi/Documents/etcher/node_modules/app-builder-lib/src/index.ts:59:28)
    at build (/home/pi/Documents/etcher/node_modules/electron-builder/src/builder.ts:228:10)
    at then (/home/pi/Documents/etcher/node_modules/electron-builder/src/cli/cli.ts:46:19)


   ╭─────────────────────────────────────────────────╮
   │                                                 │
   │       Update available 20.40.2 → 22.1.0         │
   │   Run yarn upgrade electron-builder to update   │
   │                                                 │
   ╰─────────────────────────────────────────────────╯

`

I’m no expert on this electron build stuff, but it seems like the problem is that node-gyp is downloading the x86 version fpm (what ever that is), you can see it in this like:

url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86/fpm-1.9.3-2.3.1-linux-x86.7z

which seems like a bug in the electronJs electron-builder project. I wonder if they create binaries for arm64?

This github issue: https://github.com/electron-userland/electron-builder/issues/3901 looks like what you are hitting

More specifically I think if you follow the work around the following comment proposes I think you might get past this error: https://github.com/electron-userland/electron-builder/issues/3901#issuecomment-499121694

@shaunmulligan, thanks for the heads-up but that didn’t work for me. I tried to do “gem install fpm”, that failed on permissions, so I tried “sudo gem install fpm” and got the following:

Successfully installed backports-3.15.0
Fetching: json-1.8.6.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing fpm:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.5.0/gems/json-1.8.6/ext/json/ext/generator
/usr/bin/ruby2.5 -r ./siteconf20191101-18315-1y97xqq.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/json-1.8.6 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/arm-linux/2.5.0/json-1.8.6/gem_make.out

Could you try installing fpm via the package manager, like apt-get if you are on raspbian/debian base

I can’t get fpm to install via my package manager (apt).

sudo apt install fpm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package fpm

What’s the easier path here - to try to debug the install via gem, or to play with my apt sources or otherwise get it to install via apt?

the fpm site fpm installation suggests that certain prerequisites may be necessary

apt-get install ruby ruby-dev rubygems build-essential

I get this output:

sudo apt-get install ruby ruby-dev rubygems build-essential
Reading package lists… Done
Building dependency tree
Reading state information… Done
build-essential is already the newest version (12.6).
ruby is already the newest version (1:2.5.1+b1).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
rubygems : Depends: ruby1.8 but it is not installable
Recommends: ruby1.8-dev but it is not installable
E: Unable to correct problems, you have held broken packages.

Assuming dependencies were met, they say I should be able to install fpm as follows:

sudo gem install --no-ri --no-rdoc fpm
Building native extensions. This could take a while…
ERROR: Error installing fpm:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/json-1.8.6/ext/json/ext/generator
/usr/bin/ruby2.5 -r ./siteconf20191102-1666-19q05s7.rb extconf.rb
mkmf.rb can’t find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/json-1.8.6 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/arm-linux/2.5.0/json-1.8.6/gem_make.out

Thoughts?

Just to cover our bases, have you tried running apt-get update before the apt-get install command?

try sudo apt install ruby-dev and try again

sudo apt-get install ruby ruby-dev rubygems build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done   
build-essential is already the newest version (12.6).
ruby is already the newest version (1:2.5.1+b1).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 rubygems : Depends: ruby1.8 but it is not installable
        Recommends: ruby1.8-dev but it is not installable 
E: Unable to correct problems, you have held broken packages.

@lucianbuzzo: Yes, this system is kept up to date.

It’s interesting that the error says that rubygems : Depends: ruby1.8.

Because I already have ruby 2.5.5:

pi@pi4:~ $ ruby --version
ruby 2.5.5p157 (2019-03-15 revision 67260) [arm-linux-gnueabihf]

Is the problem that rubygems is somehow needing ruby1.8 SPECIFICALLY?
Or that it’s not recognizing that I already have something more?

As you mentioned above, output of uname -a is Linux pi4 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux so I think you should build the electron for arm instead of arm64 since it’s armv7l.

Can you please try with: ./node_modules/.bin/electron-builder --arm --linux deb and let us know how it goes?