Error: Unsupported architecture on Linux: arm64
Problem
Environment:
- host: macos
- via nhost functions locally in docker
On installing the @deno/kv package I get this runtime error
functions-1 | /opt/project/functions/node_modules/@deno/kv/script/_napi_index.cjs:100
functions-1 | throw new Error(`Unsupported architecture on Linux: ${arch}`)
functions-1 | ^
functions-1 |
functions-1 | Error: Unsupported architecture on Linux: arm64
functions-1 | at Object.<anonymous> (/opt/project/functions/node_modules/@deno/kv/script/_napi_index.cjs:100:15)
functions-1 | at Module._compile (node:internal/modules/cjs/loader:1256:14)
Looking into /opt/project/functions/node_modules/@deno/kv/script/_napi_index.cjs:100 then yes there is no matching package (linux/arm64)
This is the environment you can get in docker in macos.
Solution
Maybe add an automated build for linux/arm64
This architecture is also on e.g. raspberry pi devices.
I was able to build the image on a Raspberry Pi 5:
git clone https://github.com/denoland/denokv.git
cd denokv
docker buildx build -f Dockerfile --platform linux/arm64 -t rpi5/denokv ./
Change rpi5/denokv to whatever image name you prefer.
Build took around 8 minutes.
On an M2 MacBook I've been using the linx/amd64 image with no problem. I get the warning:
denokv The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
but it still runs fine. Using Docker Desktop 4.28.0 on macOS 14.4. I did try building a native image (same command above) took a few minutes, haven't bothered to test it though.
Raspberry Pi 5:
Linux rpi5 6.6.20+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux
Docker version on Pi 5 (install guide):
Client: Docker Engine - Community
Version: 26.0.0
API version: 1.45
Go version: go1.21.8
Git commit: 2ae903e
Built: Wed Mar 20 15:18:02 2024
OS/Arch: linux/arm64
Context: default
Server: Docker Engine - Community
Engine:
Version: 26.0.0
API version: 1.45 (minimum version 1.24)
Go version: go1.21.8
Git commit: 8b79278
Built: Wed Mar 20 15:18:02 2024
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.28
GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Running fine on the Pi so far. I'll report back if any problems arise.
Official arm images would be nice now that Deno has offical arm binaries.
Yeah, it's the npm module @deno/kv that doesn't have the architecture. I am using the @deno/kv module from a node.js runtime. I don't have the ability to run my own docker image in this particular development setup, unfortunately.
But thanks for that example to create my own docker image.
That is unfortunately, what is needed to have it?
It also dont have musl builds.
It's been a while since I looked at this, but it would look something like restoring only the aarch64-unknown-linux-gnu parts out of this: https://github.com/skymethod/kv-connect-kit/commit/6ff39d26deca3ab4a1023d4d2523cd293b7e8bb5
and then add the new arch to scripts/generate_napi_index.ts