PlatformIO Community

PlatformIO & Arduino: Errors with includes

I reinstalled my PC and tried to open my old PlatformIO projects but I was getting

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit

As I wanted my default project folder to be different to the default one, I used terminal to set this as follows: platformio settings set projects_dir "C:\Users\Mat\PlatformIO-Projects"

Then in Windows file explorer I noticed .vscode folders under each project folder. I read a forum post somewhere that said you need to add the top level folder to the workspace, which I did, so I deleted these .vscode folders from the disk, removed all project subfolders from the workspace in VSC, then added the toplevel folder to the workspace: C:\Users\Mat\Projects\PlatformIO-Projects\.

I was expected the .vscode folder to re-appear in this toplevel directory after restarting VSC, however it has not and now I’m getting:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\Mat\Projects\PlatformIO-Projects\Sump Controller\src\main.cpp).

and multiple others like this:

cannot open source file "Arduino.h" (dependency of "Ethernet.h")

I then reinstalled PlatformIO within VSC but this hasn’t helped.

I’d like to reset and start over again, and set my default location for projects to my toplevel folder as above (not the default location in my home dir).

Help! Any ideas how to do this?

Answering my own post, in case it helps others.

This was resolved as follows:

  • I removed all folders from workspace. Instead of adding folders back to the workspace, I used the “open project” option in the PIO welcome screen. This resolved the issue of errors relating to the arduino.h include.
  • The other errors (for includes for libraries such as ethernet, liquidcrystal, etc.) were due to the fact that my lib_deps declaration in platformio.ini had comma-separated values. This must have worked in the previous version, however when I changed this to each library in a separate line, it magically resolved my problem.
1 Like

That is the correct behaviour… each project could have different include paths, debug task settings, seetings, etc, which are some of the things configured in that folder. It’s just unfortunate the IntelliSense database goes there also, and ends up rediciously big because it’s not being shared between projects.

That post is wrong. You want to add the contents of the top level folder, not the top level folder. The VSCode PlatformIO is looking for the platformio.ini in the root folder in order to identify the project as being a PlatformIO project, and correctly configure include paths, etc. Where things get confusing is that in a VSCode workspace, you can add multiple root folders (which is what happens when you add the Projects folder contents).

If you’ve only just reinstalled PlatformIO, it could also be in the process of reinstalling the frameworks and platform toolchains etc for the frameworks/platforms you use, which also triggers the IntelliSense/squiggles are disabled warning because the files aren’t present yet. That usually goes away after a few minutes / builds.