PlatformIO Community

PIO in VSCode doesn't find any libraries (including built-in ones)

The error that appears is “cannot open source file "Arduino.h"”.

I’ve tried everything, from reloading the project, creating a new project and copying my code into it, and more, but nothing seems to work.

Edit - I forgot 2 things.
A. The problem is only present in one specific project.
B. My platformio.ini is -

[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps = enjoyneering/LiquidCrystal_I2C@^1.2.4
  • Where is this project located? Is something like OneDrive involved?*
  • What IDE is being used?
    • if it’s VSCode, what’s the content of the .vscode/c_cpp_properties.json file?
  • Does it compile using pio run or is it only a code completion error?

Thanks for replying.

  1. The project is located in OneDrive/Documents/PlatformIO/Projects, but so are all of the other projects, so that shouldn’t be a factor.
  2. The content of the c_cpp_properties file is
{
    "configurations": [
        {
            "name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags"
        },
        {
            "name": "Win32",
            "includePath": [
                "C:/Users/shach/OneDrive/Documents/PlatformIO/Projects/LCD Display/include",
                "C:/Users/shach/OneDrive/Documents/PlatformIO/Projects/LCD Display/src",
                "C:/Users/shach/OneDrive/Documents/PlatformIO/Projects/LCD Display/.pio/libdeps/uno/LiquidCrystal_I2C/src",
                "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
                "C:/Users/shach/.platformio/packages/framework-arduino-avr/cores/arduino",
                "C:/Users/shach/.platformio/packages/framework-arduino-avr/variants/standard",
                "C:/Users/shach/OneDrive/Documents/PlatformIO/Projects/LCD Display/.pio/libdeps/uno/LiquidCrystalIO/src",
                "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
                "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/HID/src",
                "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
                "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
                "C:/Users/shach/.platformio/packages/tool-unity",
                ""
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "path": [
                    "C:/Users/shach/OneDrive/Documents/PlatformIO/Projects/LCD Display/include",
                    "C:/Users/shach/OneDrive/Documents/PlatformIO/Projects/LCD Display/src",
                    "C:/Users/shach/OneDrive/Documents/PlatformIO/Projects/LCD Display/.pio/libdeps/uno/LiquidCrystal_I2C/src",
                    "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
                    "C:/Users/shach/.platformio/packages/framework-arduino-avr/cores/arduino",
                    "C:/Users/shach/.platformio/packages/framework-arduino-avr/variants/standard",
                    "C:/Users/shach/OneDrive/Documents/PlatformIO/Projects/LCD Display/.pio/libdeps/uno/LiquidCrystalIO/src",
                    "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
                    "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/HID/src",
                    "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
                    "C:/Users/shach/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
                    "C:/Users/shach/.platformio/packages/tool-unity",
                    ""
                ]
            },
            "defines": [
                "PLATFORMIO=50000",
                "ARDUINO_AVR_UNO",
                "F_CPU=16000000L",
                "ARDUINO_ARCH_AVR",
                "ARDUINO=10808",
                "__AVR_ATmega328P__",
                ""
            ],
            "intelliSenseMode": "clang-x64",
            "cStandard": "c11",
            "cppStandard": "c++11",
            "compilerPath": "C:/Users/shach/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe",
            "compilerArgs": [
                "-mmcu=atmega328p",
                ""
            ]
        }
    ],
    "version": 4
}
  1. I run it using the default PIO upload button, and I presume PIO run.

The c_cpp_properties.json looks valid to me. In the folder

does the Arduino.h file exist, as a sanity check?

Reverse-test: Does the problem go away when moving the project out of there and pushing the Rebuild IntelliSense index button?

The Arduino.h file does exist in this folder, but if I remove the project and press “rebuild IntelliSense index”, nothing changes. I even moved it back in to see if the terminal output is different, but it was the same.

I have similar problem after updating to 5.0. Adafruit libraries files and a few other .h files not found. Build fails. Once I specified relative path to those h files it compiled. I’m not sure how that interlibrary referencing works but looks like something is not working in it.
I use slightly modified version of https://github.com/CODeRUS/GyverLampCpp

Could you remove C:/Users/shach/.platformio/packages/framework-arduino-avr and start building again? Restart VSCode.

Tried that but it didn’t help.
it’s easy to reproduce, just get zip with master branch code of GyverLampCpp and try compiling it.
thank you
Ihor

Author of that project totally disabled Library Dependency Finder, as result, PlatformIO does not see all dependencies. See my PR:

1 Like