Xtensa-esp32-elf-g++: no such file or directory

I’m having troubles with #arduino environment.

If I select Arduino Uno I get:

If I select ESP32 Dev Module:

Arduino: 1.8.12 (Linux), Board: “ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None”

fork/exec /home/XXXXX/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++: no such file or directory
Error compiling for board ESP32 Dev Module.

Actually the file is there:

ll ~/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++
-rwxr-xr-x   2 XXXXX            users      810856 2021-10-25 18:56 /home/ХХХХХ/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++

If I inspect it:

ldd ~/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++
	linux-vdso.so.1 (0x00007fff177f8000)
	libstdc++.so.6 => not found
	libm.so.6 => /nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib/libm.so.6 (0x00007ff33fd4a000)
	libc.so.6 => /nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib/libc.so.6 (0x00007ff33fb8b000)
	/nix/store/q53f5birhik4dxg3q3r2g5f324n7r5mc-glibc-2.31-74/lib/ld-linux-x86-64.so => /nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib64/ld-linux-x86-64.so.2 (0x00007ff33fe8d000)

The chip I’m trying to work with is:

Espressif, ESP32-WROOM-32

Any help will be appreciated.

Not so sure how the arduino studio is supposed to be used but in the platformio package we use an fhsuserenv environment so that we can run unpatched downloaded vendor toolchains like the xtensa one. Your issue right now is that ld-linux.so in the binaries is set to a path that does not exist on nixos in the same location. One way to make it work anyway is using GitHub - Mic92/nix-ld: Run unpatched dynamic binaries on NixOS. Another way would be fhsuserenv (here an example: https://github.com/nix-community/nix-environments/blob/2b4833ed0cda7518c5d3b345ef0b117986f4a7af/envs/spec-benchmark/shell.nix)


For more background on the topic have a look at Packaging/Binaries - NixOS Wiki