microsoft / microsoft/vscode-cpptools

Can't find headers even when in include path

Open
#9,007 18 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature: Configuration investigate: repro Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Bug type: Language Service

I'm edition something on LInux that require the "lib1" headers, it keeps asking to add "/same_path_has_MYPROJECT_INSTALL_PATH/include/lib1" to the include path, over and over, even when "${env:MYPROJECT_INSTALL_PATH}include/lib1" it's already there and points to the same path.
This happens on random files and with random libs on this project. But when i compile the errors go away and sometimes they come back later.

This issue was wrongly reported on the VSCode issues (https://github.com/microsoft/vscode/issues/144830).
I think every information is there and I will add here what's missing.

  • OS and Version: Linux x64 5.16.13-arch1-1
  • VS Code Version: 1.65.1
  • C/C++ Extension Version: 1.8.4
  • Other extensions you installed (and if the issue persists after disabling them): C/C++ Extension pack
  • If using SSH remote, specify OS of remote machine: N/A
  • VSCode sometimes randomly complains about missing paths that are on include path already and even with u add using the "quick fix" the issue doesn't go away

Steps to reproduce

  1. Have a project with some headers that need a path on the include path
  2. VSCode sometimes randomly complains about missing paths

Expected behavior

Intellsense should work and find the headers in the include path

Code sample and logs

I don't know if this output are related to this specific issue.

C/C++ output:

IntelliSense process crash detected.

cpptools output:

[Error - 2:41:14 PM] Connection to server got closed. Server will not be restarted.
  • Code sample

  • Configurations in c_cpp_properties.json
    This is an example:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${env:SystemDrive}/path_to_somewhere/include",
                ... (more struff)
                "${env:MYPROJECT_INSTALL_PATH}/include",
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "${env:SystemDrive}\\msys64\\mingw64\\bin\\gcc.exe",
            "cStandard": "gnu17",
            "cppStandard": "gnu++20",
            "intelliSenseMode": "windows-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        },
        {
            "name": "Linux",
            "includePath": [
                "${env:MYPROJECT_INSTALL_PATH}include/",
                "${env:MYPROJECT_INSTALL_PATH}include/lib1",
                "${env:MYPROJECT_INSTALL_PATH}include/lib2",
                ... (more stuff)
                "${workspaceFolder}/**",
                "/usr/include/some_stuff/",
                "/usr/lib/some_stuff/include",
                "/same_path_has_MYPROJECT_INSTALL_PATH/include/lib1"
            ],
            "cStandard": "gnu17",
            "cppStandard": "gnu++20",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}
  • Logs from running C/C++: Log Diagnostics from the VS Code command palette
    Some of the names had to be removed
    Seems that every line on the file is being properly translated
-------- Diagnostics - 3/10/2022, 2:47:37 PM
Version: 1.8.4
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**",
        "${workspaceFolder}/source/server",
        "${workspaceFolder}/source/gui",
        "/usr/include/glibmm-2.68/",
        "/usr/lib/glibmm-2.68/include",
        "/usr/include/glib-2.0/",
        "/usr/lib/glib-2.0/include",
        "/usr/include/gtkmm-4.0",
        "/usr/lib/gtkmm-4.0/include",
        "/usr/include/sigc++-3.0",
        "/usr/lib/sigc++-3.0/include",
        "/usr/lib/pangomm-2.48/include",
        "/usr/include/pangomm-2.48",
        "/usr/include/pango-1.0",
        "/usr/include/harfbuzz",
        "/usr/include/giomm-2.68",
        "/usr/lib/giomm-2.68/include",
        "/usr/include/cairomm-1.16",
        "/usr/lib/cairomm-1.16/include",
        "/usr/include/cairo",
        "/usr/include/freetype2",
        "/usr/include/gtk-4.0",
        "/usr/include/gdk-pixbuf-2.0",
        "/usr/include/graphene-1.0",
        "/usr/lib/graphene-1.0/include"
    ],
    "cStandard": "gnu17",
    "cppStandard": "gnu++20",
    "intelliSenseMode": "linux-gcc-x64",
    "configurationProvider": "ms-vscode.cmake-tools",
    "compilerPathIsExplicit": false,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "macFrameworkPath": [],
    "compilerArgs": [],
    "mergeConfigurations": false,
    "compilerPath": "/usr/bin/gcc",
    "browse": {
        "path": [
            "${workspaceFolder}/**",
            "${workspaceFolder}/source/server",
            "${workspaceFolder}/source/gui",
            "/usr/include/glibmm-2.68/",
            "/usr/lib/glibmm-2.68/include",
            "/usr/include/glib-2.0/",
            "/usr/lib/glib-2.0/include",
            "/usr/include/gtkmm-4.0",
            "/usr/lib/gtkmm-4.0/include",
            "/usr/include/sigc++-3.0",
            "/usr/lib/sigc++-3.0/include",
            "/usr/lib/pangomm-2.48/include",
            "/usr/include/pangomm-2.48",
            "/usr/include/pango-1.0",
            "/usr/include/harfbuzz",
            "/usr/include/giomm-2.68",
            "/usr/lib/giomm-2.68/include",
            "/usr/include/cairomm-1.16",
            "/usr/lib/cairomm-1.16/include",
            "/usr/include/cairo",
            "/usr/include/freetype2",
            "/usr/include/gtk-4.0",
            "/usr/include/gdk-pixbuf-2.0",
            "/usr/include/graphene-1.0",
            "/usr/lib/graphene-1.0/include",
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": [
        "/usr/include/botan-2",
        "/usr/include/gtkmm-4.0",
        "/usr/lib/gtkmm-4.0/include",
        "/usr/include/giomm-2.68",
        "/usr/lib/giomm-2.68/include",
        "/usr/include/glib-2.0",
        "/usr/lib/glib-2.0/include",
        "/usr/include/sysprof-4",
        "/usr/include/libmount",
        "/usr/include/blkid",
        "/usr/include/glibmm-2.68",
        "/usr/lib/glibmm-2.68/include",
        "/usr/include/sigc++-3.0",
        "/usr/lib/sigc++-3.0/include",
        "/usr/include/gtk-4.0",
        "/usr/include/pango-1.0",
        "/usr/include/harfbuzz",
        "/usr/include/freetype2",
        "/usr/include/libpng16",
        "/usr/include/fribidi",
        "/usr/include/cairo",
        "/usr/include/lzo",
        "/usr/include/pixman-1",
        "/usr/include/gdk-pixbuf-2.0",
        "/usr/include/graphene-1.0",
        "/usr/lib/graphene-1.0/include",
        "/usr/include/gio-unix-2.0",
        "/usr/include/cairomm-1.16",
        "/usr/lib/cairomm-1.16/include",
        "/usr/include/pangomm-2.48",
        "/usr/lib/pangomm-2.48/include",
        "/usr/include/gtk-4.0/unix-print",
        "/usr/include/pgm-5.3"
    ],
    "standard": "gnu++20",
    "compilerPath": "/usr/bin/c++",
    "compilerArgs": [
        "-g",
        "-fPIC",
        "-Werror",
        "-Wall",
        "-Wextra",
        "-std=gnu++20"
    ]
}
Custom configurations:
[ /home/user/project/code.cpp ]
{
    "defines": [],
    "standard": "gnu++20",
    "includePath": [
        "/usr/include/botan-2",
        "/usr/include/gtkmm-4.0",
        "/usr/lib/gtkmm-4.0/include",
        "/usr/include/giomm-2.68",
        "/usr/lib/giomm-2.68/include",
        "/usr/include/glib-2.0",
        "/usr/lib/glib-2.0/include",
        "/usr/include/sysprof-4",
        "/usr/include/libmount",
        "/usr/include/blkid",
        "/usr/include/glibmm-2.68",
        "/usr/lib/glibmm-2.68/include",
        "/usr/include/sigc++-3.0",
        "/usr/lib/sigc++-3.0/include",
        "/usr/include/gtk-4.0",
        "/usr/include/pango-1.0",
        "/usr/include/harfbuzz",
        "/usr/include/freetype2",
        "/usr/include/libpng16",
        "/usr/include/fribidi",
        "/usr/include/cairo",
        "/usr/include/lzo",
        "/usr/include/pixman-1",
        "/usr/include/gdk-pixbuf-2.0",
        "/usr/include/graphene-1.0",
        "/usr/lib/graphene-1.0/include",
        "/usr/include/gio-unix-2.0",
        "/usr/include/cairomm-1.16",
        "/usr/lib/cairomm-1.16/include",
        "/usr/include/pangomm-2.48",
        "/usr/lib/pangomm-2.48/include",
        "/usr/include/gtk-4.0/unix-print",
        "/usr/include/pgm-5.3"
    ],
    "compilerPath": "/usr/bin/c++",
    "compilerArgs": [
        "-g",
        "-Werror",
        "-Wall",
        "-Wextra",
        "-std=gnu++20"
    ]
}
Translation Unit Mappings:
[ /home/user/projects/code.cpp ]:
    /home/user/projects/code.hh *
    /home/user/projects/code.cpp
Translation Unit Configurations:
[ /home/user/projects/code.cpp ]:
    Process ID: 7174
    Memory Usage: 373 MB
    Compiler Path: /usr/bin/c++
    Includes:
        /usr/include/botan-2
        /usr/include/gtkmm-4.0
        /usr/lib/gtkmm-4.0/include
        /usr/include/giomm-2.68
        /usr/lib/giomm-2.68/include
        /usr/include/glib-2.0
        /usr/lib/glib-2.0/include
        /usr/include/sysprof-4
        /usr/include/libmount
        /usr/include/blkid
        /usr/include/glibmm-2.68
        /usr/lib/glibmm-2.68/include
        /usr/include/sigc++-3.0
        /usr/lib/sigc++-3.0/include
        /usr/include/gtk-4.0
        /usr/include/pango-1.0
        /usr/include/harfbuzz
        /usr/include/freetype2
        /usr/include/libpng16
        /usr/include/fribidi
        /usr/include/cairo
        /usr/include/lzo
        /usr/include/pixman-1
        /usr/include/gdk-pixbuf-2.0
        /usr/include/graphene-1.0
        /usr/lib/graphene-1.0/include
        /usr/include/gio-unix-2.0
        /usr/include/cairomm-1.16
        /usr/lib/cairomm-1.16/include
        /usr/include/pangomm-2.48
        /usr/lib/pangomm-2.48/include
        /usr/include/gtk-4.0/unix-print
        /usr/include/pgm-5.3
        /usr/include/c++/11.2.0
        /usr/include/c++/11.2.0/x86_64-pc-linux-gnu
        /usr/include/c++/11.2.0/backward
        /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include
        /usr/local/include
        /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include-fixed
        /usr/include
    Standard Version: c++20
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=110200
Total Memory Usage: 373 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 40568
Number of files parsed: 4511

Screenshots

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided c_cpp_properties.json and the C/C++: Log Diagnostics output, then reproduce the missing-header reports and the IntelliSense process crash on Linux. Done means headers already present in the include path resolve consistently and IntelliSense no longer crashes or loses the configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.