microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.54k stars 1.57k forks source link

Can't find headers even when in include path #9007

Open Samega7Cattac opened 2 years ago

Samega7Cattac commented 2 years ago

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.

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.

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



- Logs from [the language server logging](https://code.visualstudio.com/docs/cpp/enable-logging-cpp#_enable-logging-for-the-language-server)

**Screenshots**
<!-- If applicable, add screenshots to help explain your problem. -->

**Additional context**
<!--
Providing call stacks:
For bugs like crashes, deadlocks, infinite loops, etc. that we are not able to repro and for which the call stack may be useful, please attach a debugger and/or create a dmp and provide the call stacks. Windows binaries have symbols available in VS Code by setting your "symbolSearchPath" to "https://msdl.microsoft.com/download/symbols".

Instructions for attaching debugger to language service process:
https://github.com/microsoft/vscode-cpptools/wiki/Attaching-debugger-to-cpptools-or-cpptools%E2%80%90srv.

Performance analysis:
For a performance issue see instructions at https://github.com/microsoft/vscode-cpptools/wiki/Troubleshooting-Performance-Issues.
-->
Samega7Cattac commented 2 years ago

From the logs above we see the include path is in the config file and was translated correctly, so why? Screenshots: screenshot1 screenshot2

sean-mcmanus commented 2 years ago

The IntelliSense process has crashed. Are you able to provide a crash call stack and/or repro file? See https://github.com/microsoft/vscode-cpptools/wiki/Attaching-debugger-to-cpptools-or-cpptools%E2%80%90srv

Is the gtkmm folder under /usr/include/gtkmm-4.0 ?

Samega7Cattac commented 2 years ago

The IntelliSense process has crashed. Are you able to provide a crash call stack and/or repro file? See https://github.com/microsoft/vscode-cpptools/wiki/Attaching-debugger-to-cpptools-or-cpptools%E2%80%90srv

Need to wait for it to happen again

Is the gtkmm folder under /usr/include/gtkmm-4.0 ?

Yes, everything is in the right place

Samega7Cattac commented 2 years ago

@sean-mcmanus seems the crash was not related to the headers issue, I attached to cpptools-srv and reopened a file where I was having the issue and the intellsense didn't crash. I will let it run and see if I can create a second issue for the crash

sean-mcmanus commented 2 years ago

Hmm, I'm not sure why the headers are being reported as not being found then. I'll see if anyone else on our team has any ideas.

Samega7Cattac commented 2 years ago

@sean-mcmanus I opened #9022 bc of the crashes of the intellsense, it started to happen more frequently (everytime I tried to compile) and tried to attach gdb but it just exists when I hit compile and the intellsense just crashes there. Because of that I don't have much information to share on that issue

Samega7Cattac commented 2 years ago

Now this is happening in more than just a project What I find weird is both are CMake projects, can that be a clue? there's any know issue with it?

sean-mcmanus commented 2 years ago

You could potentially try removing the configurationProvider to see if that fixes it and if so compare the Includes logging in both cases to see what is different.

Samega7Cattac commented 2 years ago

After 1 month, still no issues without the configurationProvider on the config file Comparing the after and before include logs is kinda hard in this environment but I think is all the same.

ctigrisht commented 1 year ago

I am trying to get into C++ development on linux, and my cmake project is not finding header files from the include directory in the VSCode extension, but it compiles fine, this makes VSCode unusable... I need to use another editor.

This randomly happens only in certain files and not others

sean-mcmanus commented 1 year ago

@ctigrisht Do you have the CMake Tools extension installed?

ctigrisht commented 1 year ago

@ctigrisht Do you have the CMake Tools extension installed?

yes I do VSC installed it automatically

sean-mcmanus commented 1 year ago

@ctigrisht If you run C/C++: Log Diagnostics on the repro file, then you normally should see a "Custom configurations:" section with an includePath property which will show what we're receiving from CMake Tools, which would indicate if the issue is from the CMake Tools side or our extension's side.

HomyeeKing commented 1 year ago

https://github.com/microsoft/vscode-cpptools/issues/11197

I also met the same issue

ctigrisht commented 1 year ago

@sean-mcmanus what property do I have to set in order to import directories from cmake itself?

sean-mcmanus commented 1 year ago

@ctigrisht After installing the CMake Tools extension, you can set the configurationProvider setting to "ms-vscode.cmake-tools" (and running CMake: Configure).

yanggeorge commented 1 year ago

hi @Samega7Cattac

Do you have work it out?

I have similar question. But I use cmake-tools to build project.

When ever edit a litte in header file, it shows warning and error like below.

image image

If I want to remove these , I should reset CMake tool extension state every time.

I have set using cmake-tools

"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"

Samega7Cattac commented 1 year ago

hi @Samega7Cattac

Do you have work it out?

I have similar question. But I use cmake-tools to build project.

When ever edit a litte in header file, it shows warning and error like below.

image image

If I want to remove these , I should reset CMake tool extension state every time.

I have set using cmake-tools

"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"

Nope not yet