microsoft / microsoft/vscode-cpptools

Intellisense (Go to Definition) not working (No definition found) without any debug messages if ~/.cache folder is not accessible

Aperta
#12,828 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug Language Service
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Environment
  • OS and Version: Ubuntu 22.04
  • VS Code Version: 1.94.1
Version: 1.94.1
Commit: e10f2369d0d9614a452462f2e01cdc4aa9486296
Date: 2024-10-05T05:44:32.189Z
Electron: 30.5.1
ElectronBuildId: 10262041
Chromium: 124.0.6367.243
Node.js: 20.16.0
V8: 12.4.254.20-electron.0
OS: Linux x64 6.8.0-45-generic
  • C/C++ Extension Version: v1.21.6
  • If using SSH remote, specify OS of remote machine: It uses Dev Container

I encountered an issue with IntelliSense after setting the compileCommands path in c_cpp_properties.json. It appears to successfully load the specified compile_commands.json file (I verified this by setting "enableConfigurationSquiggles": true and checking the OUTPUT window under C/C++ Configuration Warnings). However, when pressing F12 to go to the definition, it shows a "No definition found" hover message, and the 'go to definition' feature doesn't work.

Image

While reading through https://code.visualstudio.com/docs/cpp/faq-cpp#_what-is-the-ipch-folder, I noticed that the ~/.cache/vscode-cpptools folder exists in a working dev container, but it's missing in the non-working dev container.

It turns out that when the container image was created, the ~/.cache and ~/.cache/pip folder were created with root permissions (due to RUN pip install .... commands). Since the dev container runs as a non-root user, the VSCode C/C++ extension is unable to create the necessary database files.

Since there were no error messages indicating the issue, I think it would be helpful if the vscode-cpptools extension could be updated to display an error message when it cannot create or access the ~/.cache/vscode-cpptools folder so users can fix the root-cause.

The Unable to access browse database. (enhance_position) message in C/C++ Diagnostics window might be a hint, but I hope a more detailed explanation is available in the C/C++ Configuration Warnings window.

Thanks!

Bug Summary and Steps to Reproduce

Bug Summary: IntelliSense is not working without any error messages

Steps to reproduce:

  1. Setup a project with IntelliSense enabled.
  2. Update the permission of ~/.cache to root (sudo chown root:root ~/.cache) and remove ~/.cache/vscode-cpptools (sudo rm -rf ~/.cache/vscode-cpptools).
  3. Reset IntelliSense Database
  4. run Developer: Reload Window command
  5. Type F12 on a member variable of the class in the .cpp code.

Expected behavior:

Go to the definition.

Configuration and Logs
{
    "configurations": [
        {
            "name": "x86_64",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/src/**",
            ],
            "defines": [],
            "cStandard": "gnu11",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64",
            "compileCommands": "/workspace/test-project/compile_commands.json",
            "mergeConfigurations": true,
            "browse": {
                "limitSymbolsToIncludedHeaders": true
            },
            "configurationProvider": "ms-vscode.cmake-tools"
        },
    ],
    "version": 4,
    "enableConfigurationSquiggles": true
}

LSP: (received) cpptools/resetDatabase
LSP: (invoked) cpptools/resetDatabase
LSP: (received) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 167)
LSP: (invoked) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 167)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: Sending response (id: 167)
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Intellisense update pending for: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp
LSP: (received) cpptools/didChangeActiveEditor: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeActiveEditor: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp
LSP: (invoked) cpptools/didChangeTextEditorSelection
IntelliSense update scheduled and TU acquisition started for: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp
LSP: (received) cpptools/getFoldingRanges: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 168)
LSP: (invoked) cpptools/getFoldingRanges: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 168)
LSP: Sending response (id: 168)
Update IntelliSense time (sec): 0.057
LSP: (received) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 169)
LSP: (invoked) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 169)
LSP: Sending response (id: 169)
LSP: (received) cpptools/getDocumentSymbols: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 170)
LSP: (invoked) cpptools/getDocumentSymbols: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 170)
LSP: $/cancelRequest (cpptools/getDocumentSymbols, id: 170)
LSP: (received) cpptools/getFoldingRanges: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 171)
LSP: (invoked) cpptools/getFoldingRanges: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 171)
LSP: Sending response (id: 171)
LSP: (received) cpptools/getDocumentSymbols: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 172)
LSP: (invoked) cpptools/getDocumentSymbols: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 172)
LSP: (received) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 173)
LSP: (invoked) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 173)
LSP: Sending response (id: 173)
LSP: (received) textDocument/hover: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 174)
LSP: (invoked) textDocument/hover: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 174)
Unable to access browse database. (enhance_position)
LSP: Sending response (id: 174)
LSP: (received) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 175)
LSP: (invoked) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 175)
LSP: Sending response (id: 175)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) textDocument/documentHighlight: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 176)
LSP: (invoked) textDocument/documentHighlight: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 176)
LSP: Sending response (id: 176)
LSP: (received) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 177)
LSP: (invoked) cpptools/getCodeActions: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 177)
LSP: Sending response (id: 177)
LSP: (received) textDocument/definition: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 178)
LSP: (invoked) textDocument/definition: file:///workspace/test-project/src/test-project/operators/receiver/receiver.cpp (id: 178)
LSP: Sending response (id: 178)
Other Extensions

No response

Additional context

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando il flusso di textDocument/definition e la condizione segnalata “Unable to access browse database. (enhance_position)” dopo cpptools/resetDatabase. Verifica come gli errori relativi a ~/.cache/vscode-cpptools raggiungono le finestre C/C++ Diagnostics e Configuration Warnings. Il lavoro è completato quando una directory della cache inaccessibile produce un avviso chiaro e utilizzabile invece del solo “No definition found.”.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, typescript, vscode
Ambito
developer-experience, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.