C++20 ranges library: fatal error: ranges: No such file or directory

Your build_flags / unflags are correct.

However, this does not change the fact that Espressif’s xtensa-esp32-toolchain is missing the necessary header files.

(Same as here: Possible to use C++20 for ESP32 with Arduino framework)