Last updated: Apr 6, 2024
Reading time·5 min
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.
Here is the complete error message.
#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)
The first thing you should try is to restart VS Code.
The editor often glitches and shows the error for no good reason.
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.If the error persists, try to close VS Code completely and reopen the editor by
issuing the code .
command from your terminal.
code .
Note that you can also open the C/C++ configuration UI using the Command Palette:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Depending on your operating system, you might be able to use a setting that automatically configures the C/C++ extension correctly.
Click on the error message in your .cpp
file.
A yellow light bulb icon should appear.
Click on the light bulb icon.
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
.
includePath
array on WindowsTo add the path to MinGW to your includePath
array on Windows:
Click on the light bulb icon.
Click on "Edit "includePath" setting.
Here is a short clip that demonstrates the process.
.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.
#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.
code .
Once you click on the 'Edit "inclduePath" setting' option, the C/C++ Configuration settings window opens.
In the IntelliSense Configurations section at the top, click on the
c_cpp_properties.json
link.
MinGW
directory on your machine.On Windows, the directory is most commonly under C:\MinGW
or
C:\Program Files\MinGW
.
MinGW
directory and then open the include
directory.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.
{ "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.
Open your C/C++ Configuration UI settings again by clicking on the light bulb icon and selecting 'Edit "inclduePath" setting'.
Under the Compiler path setting, click on the arrow to show the dropdown menu and select:
C++
.C
.${default}
from the dropdown menu.Now restart your VS Code editor.
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Issue the following command to compile your file.
g++ hello.cpp
If you are on macOS and the error persists, try to run the following command to
install the Apple version of git
.
xcode-select --install
If you are on Linux, install g++
and build-essential
.
sudo apt install g++ sudo apt install build-essential
configurationProvider
settingIf the error persists, try setting the configurationProvider
setting to
ms-vscode.cpptools
.
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.configurationProvider
property to ms-vscode.cpptools
.{ "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 }
Make sure the C/C++ extension is installed and enabled.
Ctrl
+ Shift
+ X
on Windows or Linux.Command
+ Shift
+ X
on macOS.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.
To solve the "#include errors detected based on information provided by the configurationProvider setting" VS Code C++ error:
includePath
setting in your c_cpp_properties.json
file is
configured correctly.xcode-select
(macOS) and install g++ (Linux) installed.You can learn more about the related topics by checking out the following tutorials: