Arduino IDE v2 invokes tools in an environment where `LANG=""` and `LC_ALL=`
are not set to a specific encoding, as described in:
https://github.com/arduino/arduino-ide/issues/1513#issuecomment-1293383639
The bundled adafruit-nrfutil binary is a PyInstaller-frozen app using Click,
which expects the encoding to be set to UTF-8, and throws the following error
on macOS:
Traceback (most recent call last):
File "__main__.py", line 317, in <module>
File "click/core.py", line 1134, in __call__
File "click/core.py", line 1040, in main
File "click/_unicodefun.py", line 100, in _verify_python_env
RuntimeError: Click will abort further execution because Python was
configured to use ASCII as encoding for the environment.
Consult https://click.palletsprojects.com/unicode-support/ for
mitigation steps.
This system supports the C.UTF-8 locale which is recommended.
You might be able to resolve your issue by exporting the following
environment variables:
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
So, prepends `env LANG=C.UTF-8 LC_ALL=C.UTF-8` to each invokation in macOS,
via a `.macosx` override, to force a valid locale.
To avoid duplication, the tool arguments have been moved into a `.args`
variable that is included in the normal call and the `.macosx` override.