PlatformIO Community

Cannot open source file "Arduino.h"

Code compiles and arduino specific intellisense seems to work but Arduino.h is highlighted in error with the following error shown

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\User\Documents\repos…\src\main.cpp).

cannot open source file “Arduino.h”

If I click the light bulb and follow to the include path It has just one line


Is that correct?

Please remove .vscode folder from a project and restart VSCode.


I have the same problem. Closed VSCode and removed .vscode folder from one of the projects (the only project in the workspace that has the problem) in the default location workspace. The difference is that the lightbulb now suggested to add a path. But the problem did not go away. All projects in the workspace compile fine, one tells me that Arduino.h could not be found and also compiles fine.


This seems to be a daily occurrence. Deleting the .vscode file does not help.

Every other day I create a new project, copy old files into it and it runs for an hour or a day. Then, magically, I get the dreaded "#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\Tom…\src\main.cpp).C/C++(1696)

Is there a fix for this? Deleting .vscode doesn’t help for me either.

The error is cosmetic as the code complies but the annoying errors are still there.

Also getting warnings on SPI.h and any other files I try to include, again cosmetic and the code compiles.

Have also tried disabling all extensions.

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/home/PlatformIO/Projects/test/src/main.cpp).C/C++(1696)

This has been repeating issue for a long time. Is there any fix / solution on how to really fix it?

I have nothing besides Platformio and its stuff installed atm.

1 Like

We’d need more details to help such as

  • OS
  • VSCode Version
  • Screenshot of the Extensions tab of VSCode
  • PIO Core and Extension version
  • your platformio.ini
  • .vscode/c_cpp_properties.json file of your project

Ubuntu 19.10

VS Code:
Version: 1.41.1
Commit: 26076a4de974ead31f97692a0d32f90d735645c0
Date: 2019-12-18T15:04:31.999Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Linux x64 5.3.0-29-generic

PIO: Home 3.0.1 Core 4.1.0

Screenshot from 2020-02-09 18-00-28


platform = atmelavr
board = uno
framework = arduino

monitor_speed = 115200
upload_flags = -V

lib_deps =
  # Using a library name

c_cpp_properties.json File:

So that all looks good. Do you see the Arduino.h with valid content in /home/greg/.platformio/packages/framework-arduino-avr/cores/arduino? Is the compiler invocable with

/home/greg/.platformio/packages/toolchain-atmelavr/bin/avr-gcc --version

? Can you show a screenshot of the error message?

Arduino.h file looks good.
Compiler also runs:

avr-gcc (AVR_8_bit_GNU_Toolchain_3.6.2_1759) 5.4.0


The file you shown me was for /home/greg/Documents/PlatformIO/Projects/Test, not a project called Commodore 64 USB Keyboard. Do you have multiple workspaces open at once?

Sorry, selected the incorrect file.

Here is the correct c_cpp_properties.json File:

So that looks good too. But do you have multiple workspaces open? Maybe multi-root is a problem.

When you close all workspaces except the one for your initial “Test” project, does the same error occur? Does it change when you execute the “Rebuild Intellisense” task in VSCode?

1 Like

When I open the Test project the issue is no longer there. I’ve now closed all work spaces and opened the C64 USB Keyboard project and the issue comes back.

Have also tried to rebuild the intellisense task, didn’t make any difference. Have also now upgraded to VS Code 1.42.0. Issue persists.

Just a shot in the dark, but can you rename the folder /home/greg/Documents/PlatformIO/Projects/Commodore 64 USB Keyboard to /home/greg/Documents/PlatformIO/Projects/Commodore64USBKeyboard (no spaces)?

Success! That fixed it. Weird thing is if I rename it back now to the original folder with the spaces in it stays fixed.

Maybe there is some caching going on. Can you rebuild the Intellisense and re-open VSCode after the rename to the one with spaces?

Also, are you running the latest atmelavr platform? It seems weird to me that spaces still pose a problem. What’s the output of

pio platform update

in a PIO terminal?

1 Like

Rebuilt Intellisense. Made no difference. Also closed and reopen VS Code. Can’t seem to get the error back now.

Updating atmelavr                        @ 2.0.0          [Up-to-date]
Updating toolchain-atmelavr              @ 1.50400.190710 [Up-to-date]
Updating framework-arduino-avr           @ 5.0.0          [Up-to-date]
Updating framework-arduino-avr-mightycore @ 2.0.3          [Up-to-date]
Updating framework-arduino-avr-minicore  @ 2.0.3          [Up-to-date]
Updating tool-avrdude                    @ 1.60300.190424 [Up-to-date]

Oh actually it maybe makes sense regarding the issue when one of the include folders contains a space. Since your project has /home/greg/Documents/PlatformIO/Projects/Commodore 64 USB Keyboard/include as a include path with spaces, that could be the problem.

I can see that the c_cpp_properties.json has been changed to fix a situation with spaces. Can you again open a PIO terminal and execute

pio upgrade --dev

Then restart VSCode. Then reopen the project and rebuild the intellisense. What’s the content of c_cpp_properties.json now?

The compilerPath part should be changed from

            "compilerPath": "\"/home/greg/.platformio/packages/toolchain-atmelavr/bin/avr-gcc\" -mmcu=atmega328p"

to something like

            "compilerPath": "/home/greg/.platformio/packages/toolchain-atmelavr/bin/avr-gcc"
           [..more stuff..]

And a new project with space should be no problem anymore.