I recently switched from Intel Mac to ARM-based (Apple Silicon) Mac with Apple M1 Chipset and my balenaCLI fails pushing my project.
The error message points at a wrong architecture being used. It says:
[Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
The device-type I have set on my project on Balena Cloud is an RPi4 64-Bit.
Here’s the full dump:
[Info] Starting build for balena-node-red, user g_simon_kemper
[Info] Dashboard link: https://dashboard.balena-cloud.com/apps/1972788/devices
[Info] Building on arm02
[Info] Pulling previous images for caching purposes...
[Success] Successfully pulled cache images
[main] Step 1/7 : FROM balenalib/raspberrypi4-64-python:3-stretch-run
[main] ---> 5f41c7def93e
[main] Step 2/7 : WORKDIR /usr/src/app
[main] ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
[main] ---> Running in cb72b3554c2b
[main] Removing intermediate container cb72b3554c2b
[main] ---> 0d5cc714c948
[main] Step 3/7 : COPY requirements.txt requirements.txt
[main] failed to get destination image "sha256:0d5cc714c948e51d8dd40505446bc8b833199afa005a1e09ec5e357a155f80cb": image with reference sha256:0d5cc714c948e51d8dd40505446bc8b833199afa005a1e09ec5e357a155f80cb was found but does not match the specified platform: wanted linux/arm64/v8, actual: linux/amd64
[Info] Uploading images
[Success] Successfully uploaded images
[Error] Some services failed to build:
[Error] Service: main
[Error] Error: failed to get destination image "sha256:0d5cc714c948e51d8dd40505446bc8b833199afa005a1e09ec5e357a155f80cb": image with reference sha256:0d5cc714c948e51d8dd40505446bc8b833199afa005a1e09ec5e357a155f80cb was found but does not match the specified platform: wanted linux/arm64/v8, actual: linux/amd64
[Info] Built on arm02
[Error] Not deploying release.
Remote build failed
The CLI is on latest version. The project I try to push can be found here.
Hello, since you were able to get the CLI running on your M1 Mac, I don’t think the switch to Apple silicon is the issue here. You may be running up against the issue mentioned here
Since you are only defining your base image as balenalib/%%BALENA_MACHINE_NAME%%-python:latest you are actually getting balenalib/raspberrypi4-64-python:3-stretch-run and this appears to indeed have an arch listed as linux/amd64 as seen here So my suggestion if possible is to use a newer base image by being more specific in your Dockerfile as outlined here. For instance, balenalib/%%BALENA_MACHINE_NAME%%-python:3.6-buster-run or similar which has the correct arch.
Hey, Balena Team! The Balena CLI is not yet officially supported on Apple Macs with M1 ARM chipsets. However, there is a workaround that you can use to run the Balena CLI on an Apple Mac with an M1 ARM chipset.
The workaround involves installing and running the Balena CLI inside a Docker container that runs on an x86_64 emulator. Here are the steps you can follow:
Install Docker Desktop for Mac on your Apple Mac with M1 ARM chipset. You can download it from the Docker website.
Once Docker is installed, open it and make sure it is running.
Open Terminal on your Mac and run the following command to download the Balena CLI Docker image:
docker pull balenalib/raspberrypi3-node:12-build
Once the image is downloaded, run the following command to start a new Docker container that runs the Balena CLI inside the x86_64 emulator:
docker run -it --rm --privileged --name balena-cli -v /var/run/docker.so
Moreover, If you still have any query regarding balena not working except Apple/Mac then you can further ask me for more information.
If you’re experiencing issues with the Balena CLI on an Apple Mac with an M1 ARM chipset, you may need to follow some additional steps to ensure compatibility. Here’s what you can try:
Install Rosetta 2: Balena CLI currently runs on Intel-based architectures, so you’ll need to install Rosetta 2, which allows you to run Intel-based software on Apple Silicon. To install Rosetta 2, open a Terminal window and enter the following command:
softwareupdate --install-rosetta
This command will prompt the installation of Rosetta 2 if it’s not already installed.
Install Homebrew: Homebrew is a package manager for macOS that can help simplify the installation process. If you don’t have Homebrew installed, you can install it by running the following command in the Terminal:
Install Balena CLI via Homebrew here: Once Homebrew is installed, you can use it to install the Balena CLI. Run the following command in the Terminal:
arch -x86_64 brew install balena-cli
The arch -x86_64 prefix ensures that the command runs in Rosetta 2’s compatibility mode.
Verify the installation: After the installation is complete, you can verify that the Balena CLI is working correctly. Open a new Terminal window and run the following command to check the version:
arch -x86_64 balena --version
If the Balena CLI version is displayed, it means the installation was successful.
With these steps, you should be able to use the Balena CLI on your Apple Mac with an M1 ARM chipset. Note that running the Balena CLI under Rosetta 2 might result in reduced performance compared to native Apple Silicon applications.
The statement you mentioned about the Balena CLI version being displayed indicating a successful installation is not entirely accurate. While the Balena CLI version being displayed can indicate that the CLI is properly installed, it doesn’t guarantee that the installation was completely successful or that there are no issues.
To ensure a successful installation of the Balena CLI on your Apple Mac with an M1 ARM chipset, you can follow these steps:
Open a terminal on your Mac.
Install Homebrew (if you haven’t already) by running the following command:
Once Homebrew is installed, use it to install the Balena CLI by running the following command:
Copy code
brew install balena-cli
This command will install the Balena CLI using Homebrew, which is the recommended method.
4. After the installation is complete, you can verify that the Balena CLI is installed correctly by running the following command:
Copy code
balena version
If the Balena CLI version is displayed along with other information, it indicates that the CLI is installed and available for use.
However, it’s important to note that running the Balena CLI under Rosetta 2 on Apple Silicon (M1) Macs might result in reduced performance compared to native Apple Silicon applications. For optimal performance, it’s recommended to use applications that are natively built for Apple Silicon.