ClangD uses the wrong libraries

Hello,
I’ve installed PlatformIO Core through the automated install script so it’s in my $HOME/.platformio.

Now to the problem. I created a test project (just initialized a project for the Uno board) and then I ran pio run -t compiledb to get the compile_commads.json for ClangD (which I use in NeoVim).

The problem is with Arduino.h. It is included from the correct folder

Arduino.h include path

but the problem is that Arduino.h includes stdlib.h which ClangD thinks is the system one.

stdlib.h include path

This is the issue itself, but if you want to follow the file to get the issue ClangD reports it’s this: clang: 'bits/libc-header-start.h' file not found [pp_file_not_found]

The error instdlib.h

I think that it’s an issue with the generated compile_commands.json
Any way to fix this? It prevents autocompletion from working.
(Also confirmed with VSCode ClangD extension)

Fixed in the latest PlatformIO Core release. Please run `pio upgrade command.