microsoft / microsoft/vscode-cpptools

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

Open
#12,828 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

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

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 by tracing the textDocument/definition flow and the reported “Unable to access browse database. (enhance_position)” condition after cpptools/resetDatabase. Check how failures involving ~/.cache/vscode-cpptools reach the C/C++ Diagnostics and Configuration Warnings windows. Done means an inaccessible cache directory produces a clear actionable warning instead of only “No definition found.”

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.