Hi @lorandil. Thanks so much for your report. This is a known bug:
A developer has already prepared the fix, which is ready to be deployed in the next release:
You can download the tester build of that pull request by logging in to your GitHub account, then downloading the "build-artifacts" artifact here:
Unfortunately, this is a very large download because the artifact contains all the Windows, Linux, and macOS versions of the Arduino IDE. That has since been fixed, so you can download only the tester build for the specific IDE version you want in any newer pull requests.
This was actually caused by a bug in Arduino CLI, which Arduino IDE uses for all tasks that don't related to the GUI. So the fix is to update the bundled version of Arduino CLI to the latest. You can do that yourself if you like:
Close all Arduino IDE 2.x windows.
In the Arduino IDE 2.x installation folder, open the resources/app/node_modules/arduino-ide-extension/build subfolder.
Rename the arduino-cli executable you find there to some other name (e.g., arduino-cli-original) to disable it.
Download the nightly build of Arduino CLI from the appropriate link here: Redirecting
Extract the downloaded file.
Copy the arduino-cli executable from the extracted folder to resources/app/node_modules/arduino-ide-extension/build.
After doing that, you should find that the bug is fixed.
You can also just wait a few days for the fix to be merged and become available via the nightly build of Arduino IDE 2.x.