#include errors detected. Please update your includePath

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
5 min

banner

# #include errors detected. Please update your includePath

The VS Code C++ error "#include errors detected based on information provided by the configurationProvider setting" occurs when the path to the MinGW include folder is not added to your includePath setting.

vscode include errors detected

Here is the complete error message.

shell
#include errors detected based on information provided by the configurationProvider setting. Squiggles are disabled for this translation unit (/home/borislav/Desktop/bobbyhadz-rest/bobbyhadz-c/hello.cpp).C/C++(1696) cannot open source file "header.h"C/C++(1696)

# Try restarting VS Code

The first thing you should try is to restart VS Code.

The editor often glitches and shows the error for no good reason.

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type Reload Window and select Developer: Reload Window.

restart vscode

If the error persists, try to close VS Code completely and reopen the editor by issuing the code . command from your terminal.

shell
code .

Note that you can also open the C/C++ configuration UI using the Command Palette:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type c/c++ edit configurations and select C/C++: Edit Configurations (UI).

open cpp configuration using command palette

# Using the Add to Include Path setting to automatically configure C/C++

Depending on your operating system, you might be able to use a setting that automatically configures the C/C++ extension correctly.

  1. Click on the error message in your .cpp file.

  2. A yellow light bulb icon should appear.

  3. Click on the light bulb icon.

click light bulb icon and add to include path

  1. If you see the add to "includePath":/some/path setting, click on it to automatically update your C/C++ extension config.

This should resolve the error. If the error persists, try restarting VS Code.

If you don't see the add to "includePath":/some/path setting, follow the instructions from the next subheading to manually update your includePath.

# Adding the path to MinGW to your includePath array on Windows

To add the path to MinGW to your includePath array on Windows:

  1. Place your cursor on the error message and click on it.
  2. A yellow light bulb icon should appear.

click light bulb and edit include path setting

  1. Click on the light bulb icon.

  2. Click on "Edit "includePath" setting.

Here is a short clip that demonstrates the process.

click light bulb icon and select edit include path setting

Note: make sure to open your .cpp file in a folder before selecting the 'Edit "includePath" setting', otherwise, you'd get the "Open a folder first to edit configurations" error.

My hello.cpp file for the example is as simple as follows.

hello.cpp
#include <iostream> #include <header.h> int main() { std::cout << "bobbyhadz.com"; return 0; }

The file is located in a bobbyhadz-c directory.

You can open your project folder by navigating to it with your terminal and issuing the code . command.

shell
code .
  1. Once you click on the 'Edit "inclduePath" setting' option, the C/C++ Configuration settings window opens.

  2. In the IntelliSense Configurations section at the top, click on the c_cpp_properties.json link.

open c cpp properties json file

  1. The next step is to locate the MinGW directory on your machine.

On Windows, the directory is most commonly under C:\MinGW or C:\Program Files\MinGW.

locate mingw directory

  1. Open the MinGW directory and then open the include directory.

open mingw include directory

  1. Click in the address field and copy the path to the include directory.

copy path to include directory

For me, the path is C:\MinGW\include.

Open the c_cpp_properties.json file in VS Code and add the path to the includePath array.

Note: each backslash must be escaped with a second backslash.

c_cpp_properties.json
{ "configurations": [ { "includePath": [ "${workspaceFolder}/**", "C:\\MinGW\\include" ] } ] }

Note that each backslash must be escaped with a second backslash in the path.

This way, backslash characters are treated as literal characters and not as escape characters.

add path to include to include path array

  1. Open your C/C++ Configuration UI settings again by clicking on the light bulb icon and selecting 'Edit "inclduePath" setting'.

  2. Under the Compiler path setting, click on the arrow to show the dropdown menu and select:

  • "C:/MinGW/bin/g++.exe" if you code in C++.
  • "C:/MinGW/bin/gcc.exe" if you code in C.

select compiler path

  1. Scroll down to the IntelliSense mode setting in the C/C++ Configurations GUI settings.

scroll to intellisense mode

  1. Select ${default} from the dropdown menu.

select default intellisense mode

Now restart your VS Code editor.

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type Reload Window and select Developer: Reload Window.

Issue the following command to compile your file.

shell
g++ hello.cpp

# Update xcode-select and install g++

If you are on macOS and the error persists, try to run the following command to install the Apple version of git.

shell
xcode-select --install

If you are on Linux, install g++ and build-essential.

shell
sudo apt install g++ sudo apt install build-essential

# Set the configurationProvider setting

If the error persists, try setting the configurationProvider setting to ms-vscode.cpptools.

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type c/c++ edit configurations and select C/C++: Edit Configurations (JSON).

c cpp edit configurations json

  1. Set the configurationProvider property to ms-vscode.cpptools.
c_cpp_properties.json
{ "configurations": [ { "name": "Linux", "includePath": ["${workspaceFolder}/**"], "defines": [], "compilerPath": "/usr/bin/gcc", "cStandard": "c17", "cppStandard": "gnu++17", "intelliSenseMode": "linux-gcc-x64", "configurationProvider": "ms-vscode.cpptools" } ], "version": 4 }

set configurationprovider property to ms vscode cpptools

  1. Restart VS Code after setting the property.
  2. Check if the error has been resolved.

# Make sure the C/C++ extension is installed and enabled

Make sure the C/C++ extension is installed and enabled.

  1. Click on Extensions in the left sidebar.
  • You can also open the Extensions menu by pressing:
    • Ctrl + Shift + X on Windows or Linux.
    • Command + Shift + X on macOS.
  1. Type c/c++.

vscode install hex editor extension

  1. Make sure the extension is installed and enabled.

make sure cpp extension installed and enabled

You should have the C/C++ extension from Microsoft installed.

You can try to disable it and reenable it.

I've also written an article on how to install an older version of an extension in VS Code if you got the error after updating the extension.

# Conclusion

To solve the "#include errors detected based on information provided by the configurationProvider setting" VS Code C++ error:

  1. Make sure the includePath setting in your c_cpp_properties.json file is configured correctly.
  2. Make sure you have xcode-select (macOS) and install g++ (Linux) installed.
  3. Make sure the C/C++ extension is installed and enabled.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.