[Solved] Compilation Error: "cannot open source file "pins_arduino.h"" and IntelliSense

Hello everyone!

I want to share my experience in solving a problem that arose after I changed my PlatformIO configuration by downloading libraries. I wanted to work with a Waveshare ESP32-C6 board, but I couldn’t connect to it, and instead, an error occurred.

The Problem

Visual Studio Code with the PlatformIO extension constantly showed IntelliSense errors, such as #include errors detected. Please update your includePath. When trying to compile the project for ESP32, the build would always fail with this message:

cannot open source file "pins_arduino.h" (dependency of "Arduino.h") ... compilation terminated. *** [.pio\build\hornbill32dev\FrameworkArduino\Esp.cpp.o] Error 1 ========================= [FAILED] Took 13.61 seconds =========================

What I Tried (and What Didn’t Help)

Before finding the right solution, I went through many standard methods, but nothing worked:

  • Reinstalling Visual Studio Code: This was the first thing I tried, but it had absolutely no effect. The errors returned immediately after installation.
  • Constantly trying to fix the includePath: Since the initial error pointed to #include issues, I repeatedly tried to update the configuration, rebuild the IntelliSense index, and clear the cache.
  • Various project manipulations: I tried cleaning the project (pio run -t clean) and manually deleting the .pio folder for a complete rebuild, but the compiler got stuck at the same point every time.

Overall, I spent a lot of time on standard steps, but the problem turned out to be deeper.

The Solution

What helped was a complete “deep” reinstallation, clearing all remnants of PlatformIO (I deleted the .platformio directory in the user’s home directory).

The Result

After applying this fix, the project finally compiled successfully!

Building .pio\build\lilygo-t-display\firmware.bin ... ========================= [SUCCESS] Took 41.97 seconds --=========================

And here is the full error code
#include “pins_arduino.h”
^~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\hornbill32dev\FrameworkArduino\Esp.cpp.o] Error 1
========================================= [FAILED] Took 13.61 seconds =========================================

  • The terminal process “C:.platformio\penv\Scripts\platformio.exe ‘run’” terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it.