Repository navigation
Unable to resolve compilerPath with msys2's GCC #13622
Copy link
Copy link
Closed
Labels
Language Servicebugcompiler supportfixedCheck the Milestone for the release in which the fix is or will be available.Check the Milestone for the release in which the fix is or will be available.
Milestone
Description
Environment
- OS and Version: Windows 11 24H2 (26100.4061)
- VS Code Version: 1.100.2
- C/C++ Extension Version: 1.25.3
Bug Summary and Steps to Reproduce
The extension is unable to resolve the compiler path set in c_cpp_properties.json, which makes it fall back to a default, which it also fails to resolve.
I'm not sure what are the exact steps to reproduce it, but it occurs on a fresh workspace, with a fresh installation of the msys2 environment, with the latest version of the mingw-w64-ucrt-x86_64-gcc package installed.
Configuration and Logs
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/msys64/ucrt64/bin/g++.exe",
"intelliSenseMode": "windows-gcc-x64",
"cStandard": "gnu23",
"cppStandard": "gnu++23"
}
],
"version": 4
}
C/C++: Log Diagnostics
-------- Diagnostics - 5/21/2025, 10:26:48 AM
Version: 1.25.3
Current Configuration:
{
"name": "Win32",
"includePath": [
"c:/Users/[user]/[folder]/repos/[folder]/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/msys64/ucrt64/bin/g++.exe",
"intelliSenseMode": "windows-gcc-x64",
"cStandard": "gnu23",
"cppStandard": "gnu++23",
"compilerPathIsExplicit": true,
"cStandardIsExplicit": true,
"cppStandardIsExplicit": true,
"intelliSenseModeIsExplicit": true,
"recursiveIncludesReduceIsExplicit": false,
"recursiveIncludesPriorityIsExplicit": false,
"recursiveIncludesOrderIsExplicit": false,
"compilerPathInCppPropertiesJson": "C:/msys64/ucrt64/bin/g++.exe",
"mergeConfigurations": false,
"recursiveIncludes": {},
"browse": {
"limitSymbolsToIncludedHeaders": true
}
}
Modified Settings:
{
"C_Cpp.autocompleteAddParentheses": true,
"C_Cpp.clang_format_sortIncludes": true,
"C_Cpp.loggingLevel": "Debug",
"C_Cpp.autoAddFileAssociations": false
}
Additional Tracked Settings:
{
"editorTabSize": 4,
"editorInsertSpaces": true,
"editorAutoClosingBrackets": "languageDefined",
"filesEncoding": "utf8",
"filesAssociations": {},
"filesExclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.DS_Store": true,
"**/Thumbs.db": true
},
"filesAutoSaveAfterDelay": true,
"editorInlayHintsEnabled": true,
"editorParameterHintsEnabled": true,
"searchExclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true
},
"workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.25.3.0
Current database path: C:\USERS\[user]\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\4E5EE534AAC885FDEF080DF04991D11C\.BROWSE.VC.DB
Translation Unit Mappings:
[ C:\Users\[user]\[folder]\repos\[folder]\src\main.cpp - source TU]:
Translation Unit Configurations:
[ C:\Users\[user]\[folder]\repos\[folder]\src\main.cpp ]
Process ID: 1132
Memory Usage: 58 MB
Include paths:
Defines:
_DEBUG
UNICODE
_UNICODE
Standard Version: ms_c++17
IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 58 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 3
Language server logging
loggingLevel: 6
LSP: (received - deferred) textDocument/didOpen: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/
LSP: (received) cpptools/initialize (id: 1)
LSP: (invoked) cpptools/initialize (id: 1)
cpptools version (TypeScript): 1.25.3
cpptools version (native): 1.25.3.0
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
LSP: Sending response (id: 1)
LSP: (received) cpptools/queryCompilerDefaults (id: 2)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 2)
Querying compiler for default C++ language standard using command line: C:\msys64\ucrt64\bin\gcc.exe -x c++ -E -dM nul
Querying compiler for default C++ language standard using command line: C:\msys64\ucrt64\bin\gcc.exe -x c++ -E -dM /dev/null
Detected language standard version: c++98
Querying compiler's default target using command line: "C:\msys64\ucrt64\bin\gcc.exe" -dumpmachine
Compiler returned default target value: x86_64-w64-mingw32
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
Attempting to get defaults from C compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
LSP: Sending response (id: 2)
LSP: (received) cpptools/queryCompilerDefaults (id: 3)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 3)
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
LSP: (received) cpptools/didChangeCppProperties (id: 4)
LSP: (received - deferred) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeSettings
LSP: (received) cpptools/didChangeSettings
LSP: (received) cpptools/didChangeSettings
LSP: (received) cpptools/didChangeSettings
LSP: (received - deferred) cpptools/getFoldingRanges: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/ (id: 5)
LSP: $/cancelRequest (cpptools/getFoldingRanges, id: 5)
LSP: Message ignored due to no registered handler: $/setTrace
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
LSP: (received) cpptools/didChangeSettings
LSP: (received - deferred) cpptools/getDocumentSymbols: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/ (id: 6)
Attempting to get defaults from C compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
LSP: Sending response (id: 3)
LSP: (invoked) cpptools/didChangeCppProperties (id: 4)
Code browsing service initialized
Populating file name cache...
Querying compiler for default C++ language standard using command line: C:/msys64/ucrt64/bin/g++.exe -x c++ -E -dM nul
Done populating filename cache. Elapsed time: 1 ms
Querying compiler for default C++ language standard using command line: C:/msys64/ucrt64/bin/g++.exe -x c++ -E -dM /dev/null
Detected language standard version: c++98
Querying compiler's default target using command line: "C:/msys64/ucrt64/bin/g++.exe" -dumpmachine
Compiler returned default target value: x86_64-w64-mingw32
Compiler query command line: C:/msys64/ucrt64/bin/g++.exe -std=gnu++23 -m64 -Wp,-v -E -dM -x c++ nul
Compiler query command line: C:/msys64/ucrt64/bin/g++.exe -std=gnu23 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:/msys64/ucrt64/bin/g++.exe -std=gnu23 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:/msys64/ucrt64/bin/g++.exe -std=gnu++23 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:/msys64/ucrt64/bin/g++.exe -std=gnu++23 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:/msys64/ucrt64/bin/g++.exe -std=gnu23 -Wp,-v -E -dM -x c nul
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:/msys64/ucrt64/bin/g++.exe'
Attempting to get defaults from C compiler in "compilerPath" property: 'C:/msys64/ucrt64/bin/g++.exe'
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=gnu++23 -m64 -Wp,-v -E -dM -x c++ nul
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=gnu23 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=gnu23 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=gnu++23 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=gnu++23 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=gnu23 -Wp,-v -E -dM -x c nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Folder: C:\USERS\[user]\[folder]\REPOS\[folder] will be indexed
LSP: (queued) textDocument/didOpen: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/
LSP: (queued) cpptools/didChangeVisibleTextEditors
LSP: (queued) cpptools/getFoldingRanges: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/ (id: 5)
LSP: (queued) cpptools/getDocumentSymbols: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/ (id: 6)
LSP: Sending response (id: 4)
LSP: (invoked) cpptools/getDocumentSymbols: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/ (id: 6)
LSP: (invoked) cpptools/didChangeSettings
Discovering files...
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: (invoked) cpptools/didChangeSettings
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: (invoked) cpptools/didChangeSettings
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: (invoked) cpptools/didChangeSettings
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
Processing folder (recursive): C:\USERS\[user]\[folder]\REPOS\[folder]
LSP: (invoked) cpptools/didChangeSettings
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: (invoked) textDocument/didOpen: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/
LSP: Sending response (id: 6)
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Intellisense update pending for: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/ (id: 5)
LSP: Request canceled by server (<unknown/completed>, code: -32802, id: 5)
Discovering files: 3 file(s) processed
0 file(s) removed from database
Done discovering files.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
IntelliSense update scheduled and TU acquisition started for: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/
Expanding recursive includes for: C:\USERS\[user]\[folder]\REPOS\[folder]\SRC\MAIN.CPP
Done expanding recursive includes for: C:\USERS\[user]\[folder]\REPOS\[folder]\SRC\MAIN.CPP
Reducing recursive includes for: C:\USERS\[user]\[folder]\REPOS\[folder]\SRC\MAIN.CPP
Done reducing recursive includes for: C:\USERS\[user]\[folder]\REPOS\[folder]\SRC\MAIN.CPP
sending compilation args for C:\Users\[user]\[folder]\repos\[folder]\src\main.cpp
define: _DEBUG
define: UNICODE
define: _UNICODE
stdver: ms_c++17
intelliSenseMode: windows-msvc-x64
Update IntelliSense time (sec): 0.047
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/ (id: 7)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/[user]/[folder]/repos/[folder]/src/main.cpp/ (id: 7)
LSP: Sending response (id: 7)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditorsReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Language Servicebugcompiler supportfixedCheck the Milestone for the release in which the fix is or will be available.Check the Milestone for the release in which the fix is or will be available.
Type
Projects
- StatusShow more project fieldsDone
Activity
Katzenwerfer commentedon May 21, 2025
For the record, this occurs even when the C/C++ extension is the only one enabled in the editor.
bobbrow commentedon May 21, 2025
Hi Jones (@Katzenwerfer),
We received a recent report similar to this but we were unable to reproduce the problem and the thread eventually died. Can you look at this comment: #13519 (comment) and check if those steps improve the situation for you?
You can also try running the compiler query command directly in a CMD shell and see if you are able to get more error details.
C:\msys64\ucrt64\bin\gcc.exe -x c++ -E -dM /dev/nullKatzenwerfer commentedon May 21, 2025
Path-wise, I have everything set correctly. I'm sure that can be corroborated by calling GCC through any shell, which works fine on my end.
I also found no issues whenever I tried compiling a random file. However, I did find an issue querying that in a fresh CMD shell.
My first guess is that something broke in the package with a recent update. If that's the case, I'll try reporting it to the msys2 team.
Colengms commentedon May 21, 2025
Hi Jones (@Katzenwerfer) . When querying a compiler, in order to support MSYS64, the C/C++ Extension will temporarily add the compiler's path to the PATH environment variable. To run the query manually, I'd suggest:
(Note the use of the
nulversion of the command, which is tried first and worked for me.)You might consider checking your system's PATH environment variable for issues that might cause it to misinterpret a path added to the end.
Also, if you temporarily set
"C_Cpp.loggingLevel": "7", that will cause log output to be very verbose but will include the actual output of the compiler query attempt.bobbrow commentedon May 21, 2025
oh, wow, I didn't even realize I lifted a
/dev/nullfrom the logs and put it in my comment. That must have been from a Cygwin query attempt. Bad luck on my part. 😄Katzenwerfer commentedon May 21, 2025
That seemed to run fine...
I wouldn't know why it wouldn't work from outside that path. I guess I might have installed something that is messing with the user/system Path, but then I wouldn't know how to spot that, and for all I know both have been the same for a while now.
Tried that, but I couldn't spot any meaningful output that wasn't included in the log in the original post.
Colengms commentedon May 21, 2025
With that setting set, I get the following:
If you're not seeing any additional information at all, that would seem to imply that the compiler cannot be executed at all for some reason. Could you try launching VS Code as Administrator, to see if that avoids the issue? If so, it may have something to do with security settings on your machine.
Also, do you have a secondary machine (or VM instance) to try this on? Since this is working for me locally, I suspect it has something to do with your environment. Whether or not this works for you in another environment may narrow things down.
Colengms commentedon May 21, 2025
It's interesting that 2 of the 3 types of queries were successful:
Another interesting thing I'm noticing is that all of the queries that were passed
nulappear to have failed, while one of the above successful results involved use of/dev/null. That is behavior I would expect from Cygwin, not MSYS64+MinGW+ucrt64.nulworks for me locally. When you manually ran the query successfully, did you usenulor/dev/null?Could you check the version of gcc you have installed? I get the following:
Katzenwerfer commentedon May 21, 2025
I could spin-up a VM to try a fresh environment, though I think I narrowed it down. I have Meld installed and added to my system path. It seems like some libraries in the folder were overriding msys2's. To confirm it, I isolated all DLLs from both and tried querying again within each set, and indeed, Meld's files were the ones causing the issue.
Moving msys2's folders higher in my system path fixes it. Though, I do have to wonder how I never noticed this before.
Colengms commentedon May 21, 2025
Hi Jones (@Katzenwerfer) . I think we can mitigate this type of issue by temporarily adding the compiler's path to the start of the list of PATHs instead of the end, when querying a compiler.
Katzenwerfer commentedon May 21, 2025
Yeah, that works fine. I'll be closing this now.
I do think it's weird that it fails the queries, since the folder is added to the path by the extension when doing them. I would've assumed it would get higher priority, but I guess not.
Katzenwerfer commentedon May 21, 2025
For the record, the conflicting file was Meld's
libwinpthread-1.dll.This issue on the MSYS2-packages repository recommends checking for other folders in the path that include that file.
msys2/MSYS2-packages#5389 (comment)
sean-mcmanus commentedon May 23, 2025
Jones (@Katzenwerfer) Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.26.1