Can't build anything on Raspberry PI

Hey all,
I’ve installed VSCode and then installed Platform IO on a Raspberry Pi 4. In the terminal I see this appear after PlatformIO is installed and reloaded…

“Unable to resolve configuration with compilerPath “/home/xxx/.platformio/packages/toolchain-atmelavr/bin/avr-gcc”. Using “/usr/bin/gcc” instead”

In the editor, in main.cpp I get squiggles under #include <Arduino.h> and the following errors:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/home/xxx/Documents/PlatformIO/Projects/Blink2/src/main.cpp).

cannot open source file “Arduino.h”

When I try build I get the following error in the Terminal:

Processing uno (platform: atmelavr; board: uno; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (4.2.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr @ 5.1.0 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/uno/src/main.cpp.o
Archiving .pio/build/uno/libFrameworkArduinoVariant.a
avr-g++: error: device-specs/specs-atmega328p: No such file or directory
avr-gcc-ar: Cannot find plugin 'liblto_plugin.so'
Compiling .pio/build/uno/FrameworkArduino/CDC.cpp.o
avr-g++: error: device-specs/specs-atmega328p: No such file or directory
*** [.pio/build/uno/src/main.cpp.o] Error 1
Compiling .pio/build/uno/FrameworkArduino/HardwareSerial.cpp.o
*** [.pio/build/uno/libFrameworkArduinoVariant.a] Error 1
*** [.pio/build/uno/FrameworkArduino/CDC.cpp.o] Error 1
avr-g++: error: device-specs/specs-atmega328p: No such file or directory
*** [.pio/build/uno/FrameworkArduino/HardwareSerial.cpp.o] Error 1

I’ve tried reinstalling VSCode and PlatformIO. I’ve deleted the .platformio directory in /Home/User

Any advice would be great.

Well that definitely looks like corrupted packages.

Do again a

rm -rf ~/.platformio/packages/toolchain-atmelavr
rm -rf ~/.platformio/packages/framework-arduino-avr
rm -rf ~/.platformio/.cache

and build again. Does it work? If not, what’s the output of

~/.platformio/packages/toolchain-atmelavr/bin/avr-gcc --version
pio system info

on the PlatformIO CLI?

It still didn’t build

~/.platformio/packages/toolchain-atmelavr/bin/avr-gcc --version
bash: /home/xxx/.platformio/packages/toolchain-atmelavr/bin/avr-gcc: No such file or directory

^That file exists, I can navigate there in the file explorer and terminal. If I change directory in the terminal to:
cd ~/.platformio/packages/toolchain-atmelavr/bin

I can then run avr-ar --version and get:

GNU ar (GNU Binutils) 2.26.20160125
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

pio command does not work from the terminal

I’m running the 64bit OS on a Raspberry Pi. Doing a bit of googling and I read that 32bit executables will say ‘No such file or directory’ if you try to run them. I couldn’t find a solution though and not sure this is the issue.

Yeah if originally had a 32-bit install of Raspbian and then upgraded to 64-bit it’s game over and the same as in ESP8266: Upload fails - xtensa-lx106-elf-g++: not found - #5 by kdebarb63

I didn’t upgrade to 32bit. This was a clean 64b install.

Then what’s the output of

cd ~/.platformio/packages/toolchain-atmelavr/bin/
ls -lha
ldd avr-g++
df -h /
uname -a

?