Julia 1.7.1 on M1 fails on `Pkg.build()`

ERROR: Error building `NNlib`: 
┌ Warning: Platform `arm64-apple-darwin21.2.0` is not an officially supported platform
└ @ BinaryProvider ~/.julia/packages/BinaryProvider/U2dKK/src/PlatformNames.jl:450
ERROR: LoadError: KeyError: key "unknown" not found

How to solve the issue or at least fix the environment?


Running Julia natively on MacOS on ARM chips, such as the M1, currently has only "Tier 3" support. This means

Tier 3: Julia may or may not build. If it does, it is unlikely to pass tests. Binaries may be available in some cases. When they are, they should be considered experimental. Ongoing support is dependent on community efforts.

For individual packages, if they have binary dependencies, it depends on how those are provided. If they are provided by the modern BinaryBuilder.jl / Yggdrasil.jl infrastructure, those binary dependencies may be available for arm64-apple-darwin; if they use some older system for binary dependencies, that will almost certainly not support Mac on ARM.

In the meanwhile, you might instead use the macOS x86 (Intel or Rosetta) release from https://julialang.org/downloads/ for production work; this should cause both Julia itself and any package binary dependencies to run using x86 binaries via Rosetta, and should generally work without error on M1.