microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.47k stars 451 forks source link

#include errors detected based on information provided by the configurationProvider setting. #3410

Open DerNils-git opened 12 months ago

DerNils-git commented 12 months ago

Environment

C_CPP.log

Bug Summary and Steps to Reproduce

Bug Summary:

  1. include errors detected based on information provided by the configurationProvider setting. Squiggles are disabled for this translation unit (/raven/u/nilsch/codes/bsl6d/src/grid/grid.hpp).

  2. cannot open source file "Kokkos_Core.hpp" (None of the include files are detected)

These errors occur independent of which file of the project is opened. For none of the files any includes can be found.

Steps to reproduce:

  1. Connect to remote server
  2. Configure and build project using CMake
  3. Open any file of project
  4. Returns error message above

Might be related to microsoft/vscode-cpptools#11073, microsoft/vscode-cpptools#11306

Configuration and Logs

Logging file is provided above using `loggingLevel: Debug`

Other Extensions

Additional context

No response

Colengms commented 12 months ago

Hi @DerNils-git . (Based on my comments here: https://github.com/microsoft/vscode-cpptools/issues/11306#issuecomment-1781924298 ) I see from your logs that the CMake Tools extension is registered as a custom configuration provider and does provide a 'browse configuration' (which is used to determine what folders should be parsed to populate the C/C++ extension's syntactic/lexical 'browse' database of all files). When a custom configuration provider can provide a configuration for a specific file (uri/path), it should deliver a configuration for that file when requested (which happens as the file is opened). However, I don't see any occurrences of Custom configurations received: in the log you provided, so CMake Tools doesn't appear to be able to provide a configuration. Assuming you're able to successfully build using CMake on that machine, the issue would seem to be specific to CMake Tools. If there are symlinks involved, perhaps the paths used by VS Code are not properly resolving to the same files known to CMake. I'm going to go ahead and move this issue into the CMake Tools repro.

DerNils-git commented 12 months ago

For completeness the log file of CMake-Tools in mode debug cmake_tools.log and CMake Log Diagnostics file cmake_log_diagnostics.json

snehara99 commented 12 months ago

Hi @DerNils-git could you also provide your CMake Log Diagnostics please? You can get it by running CMake: Log Diagnostics in the command pallet.

DerNils-git commented 11 months ago

I added it to the previous comment to keep the log files together

snehara99 commented 11 months ago

Thanks @DerNils-git! Our team will investigate this issue as soon as it's possible for us :)

snehara99 commented 11 months ago

Hi @DerNils-git I don't see anything off about the CMake logs you provided. Would it be possible to give us a sample project that reproduces the issue? It is hard to investigate without being able to reproduce the error. Thanks!

DerNils-git commented 11 months ago

The project is open source and available at but I don't think it is connected to the project.

I created a minimal example where the same error occurs. Maybe this helps to reproduce the problem. The error messages are:

#include errors detected based on information provided by the configurationProvider setting. Squiggles are disabled for this translation unit (/raven/u/nilsch/codes/minExample/main.cpp).
cannot open source file "Kokkos_Core.hpp"
cannot open source file "nlohmann/json.hpp"
CMAKE_MINIMUM_REQUIRED (VERSION 3.24)

PROJECT (BSL6D LANGUAGES CXX)

SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
FetchContent_Declare(
  Kokkos
  GIT_REPOSITORY https://github.com/kokkos/kokkos.git
  GIT_TAG aa1f48f3172069f212ed2c97b74b786999b26f17
)
FetchContent_Declare(
  nlohmann_json
  GIT_REPOSITORY https://github.com/nlohmann/json.git
  GIT_TAG 6af826d0bdb55e4b69e3ad817576745335f243ca
  OVERRIDE_FIND_PACKAGE
)

FetchContent_MakeAvailable(Kokkos nlohmann_json)

add_executable(main main.cpp)
target_link_libraries(main PUBLIC Kokkos::kokkos nlohmann_json::nlohmann_json)

main.cpp

#include <Kokkos_Core.hpp>
#include <nlohmann/json.hpp>

#include <iostream>

int main(int argc, char* argv[]){

    std::cout << "Hello World\n";
    return EXIT_SUCCESS;
}

CMakeUserPresets.json

{
  "version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 22,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "mpcdf-env",
      "displayName": "GCC Compiler",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release",
        "CMAKE_CXX_EXTENSIONS":"Off",
        "CMAKE_CXX_COMPILER": "g++"
      }
    }
  ]
}

Log-Files: C_Cpp.log CMake_Diagnostics.log CMake_Tools.log

gcampbell-msft commented 11 months ago

@DerNils-git Great! Thanks for all of that information, I've put it on our backlog and marked it as needing investigation. We will work towards getting a developer on this dependent on bandwidth.

Nullarity commented 10 months ago

I probably have the same issue. I manage to build, debug, and run my project, but what bothers me most is the inconsistency of the error messages and my inability to understand their root cause. In the following screenshot, you can see this:

error

However, let me close VSCode and open it again, that error disappears for a while, but then I will see this again like "file not found" or like "#include errors detected based on information provided". Meanwhile, Intellisense recognizes the function signature, but the 'Go to definition' command doesn’t work:

f12

I've tried cmake / cleaning the cache, and other "resets", but nothing helps.

p.s. One more thing I want to mention: my project is CMake-based. I know that 'configurationProvider' can be used to define a provider, so for testing purposes, I excluded it from c_cpp_properties.json and used 'includePath' instead. The result, however, was the same.


vscode 1.84.2, C/C++ v1.18.5, CMake Tools v1.16.32, Linux Mint 21.2 Cinnamon

DerNils-git commented 9 months ago

The problem seems to arise if the directory ~/<MYPROJECT> is only associated to a soft link.

!> echo $HOME
/u/<USERNAME>

The root directory has the following structure:

!> ls -all /
...
drwxr-xr-x      5 root root   4096 Mar 25  2022 <SERVERNAME>
lrwxrwxrwx    1 root root      8 Mar 29  2021 u -> /<SERVERNAME>/u
...

If the project is opened using /<SERVERNAME>/u/<USERNAME>/<MYPROJECT> IntelliSense works fine. I still have to check whether I can reproduce this problem locally as well.

gkodinov commented 8 months ago

I am having the same issue. Only when I do ssh remote to a linux box. On my local windows I do not have issues like this.

The code compiles perfectly well!

image

w4133d commented 7 months ago

I'm getting the same thing: image And I don't understand why

For reference, here is my c_cpp_properties.json file: c_cpp_properties.json

Also, my configuration provider is "none": image

Colengms commented 7 months ago

Hi @w4133d . It looks like you have the following in your c_cpp_properties.json:

"configurationProvider": "ms-vscode.cpptools"

The C/C++ Extension itself is not a custom configuration provider, so this value is incorrect. I believe one of the two error message you are seeing may be related to having this field set, despite its value not actually being usable.

The error indicating iostream not being locatable would seem to suggest that either the C/C++ extension was unable to query your compiler (M:/src/msys2/ucrt64/bin/g++.exe) for the location of its system headers, or perhaps the package containing C++ headers was not properly installed with MSYS. I'd suggest enabling logging for the C/C++ Extension using "C_Cpp.loggingLevel": "Debug", and providing that output in a new issue in the C/C++ Extension repo.