balena_cli 32 bit version

Hi, Is there version of this compatible with 32 bit? Cheers

Hello, We don’t offer 32bit binary releases I’m afraid. However, you should be able to use the NPM installation method described here: https://github.com/balena-io/balena-cli/blob/master/INSTALL.md#npm-installation

Maybe the following will help someone to save time. This is mostly about downloading a Node.js unofficial build or compiling it from source. Maybe there are better methods, here are mine.

Installing Balena Cli on a x86 Linux PC with NPM method (at the time of writing, balena-cli version 18.2.33)

Following is tested on my 32-bit Thinkpad X60, Debian 12 (Bookworm) i386

First steps I did as on the NPM Installation readme:
https://github.com/balena-io/balena-cli/blob/master/INSTALL-ADVANCED.md#npm-installation

sudo apt-get update && sudo apt-get -y install curl python3 git make g++
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

To continue, you have 2 options.
Option 1. Download unofficial pre-built Node for Linux x86
https://unofficial-builds.nodejs.org/download/release/
(at the time of writing, Node.js 20.15.1 was available)

To download via nvm, edit ~/.nvm/nvm.sh to add a line near 2069:

local MIRROR
  MIRROR="$(nvm_get_mirror "${FLAVOR}" "${TYPE}")"
  MIRROR="https://unofficial-builds.nodejs.org/download/release"
  if [ -z "${MIRROR}" ]; then
    return 2
  fi

Open a new terminal, so .bashrc is sourced.
Then run:
nvm install 20

It will be quite quick, a few minutes.

nvm use 20

Install Balena next.
npm install balena-cli --global --omit=dev
It will take a few minutes.

At this point, you should be done. If not, good luck with option 2!

Option 2. Build Node.js from source
Compiling Node.js from source will take many-many hours on a x86 machine. Also, if it fails, the nvm script deletes the source and next time it starts over! You can comment out this remove command near line 2300 of ~/.nvm/nvm.sh:

    # command rm -rf "${TMPDIR-}"
    return 1

Change ~/.nvm/nvm.sh to add a waiting point (add two lines after line 2295):

    nvm_cd "${TMPDIR}" && \
    nvm_echo 'Make changes in the source folder (.cache/) and press enter if ready to start compiling' && \
    command read && \
    nvm_echo '$>'./configure --prefix="${VERSION_PATH}" $ADDITIONAL_PARAMETERS'<' && \

Source again. For this, just close previous terminal, open a new terminal.

nvm install 20
# I have 2 cores on the CPU, I want to compile faster, I do:
# NVM_MAKE_JOBS=2 nvm install 20

Start nvm install 20, press Enter, but don’t press enter just yet after download is completed. Keep terminal open, open a new terminal, solve 2 issues in the Node.js source code. For the BUILD.gn and zlib.gyp changes shown later, the changes have to be done after unpacking and before configure and make.

Issue 1: Assembler compiler has problems with ifdef in openssl config
https://github.com/nodejs/node/issues/44822
Change %ifdef and %endif to #ifdef and #endif

# In Bash or other shell:
cd ~/.nvm/.cache/src/node-v20.15.1/files
for f in $(find deps/openssl/config/archs/linux-elf -type f -name '*.S'); \
do echo $f; sed -i "s/%ifdef/#ifdef/" "$f"; \
sed -i "s/%endif/#endif/" "$f"; done

Issue 2: zlib will not build natively on x86 with optimizations enabled.
https://github.com/nodejs/node/issues/33019

Let’s remove the optimizations.
cd ~/.nvm/.cache/src/node-v20.15.1/files/deps/zlib

Change zlib BUILD.gn lines 80-81, leave only 64-bit:

use_x86_x64_optimizations =
    (current_cpu == "x64") && !is_ios

Change zlib.gyp lines to remove ia32:
Lines 19, 42, 141, 161, 208:
['target_arch in "x64" and OS!="ios"', {
Line 201:
['(target_arch in "x64" and OS!="ios") or arm_fpu=="neon"', {

Press enter in the other terminal that was waiting for starting the compilation.

Takes many hours to compile (10-14 hours on single core with Thinkpad X60)

If compilation is successful, you can use Node.js version 20:
nvm use 20

Finally, you can install Balena. As non-root user:
npm install balena-cli --global --production

jaan@thinkpad-x60:~$ balena --version
18.2.33