microsoft / vscode-cpptools

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

Unable to exclude symlinked folder #2375

Closed sean-mcmanus closed 1 week ago

sean-mcmanus commented 6 years ago

Copied from https://github.com/Microsoft/vscode-cpptools/issues/2156#issuecomment-411328125 .

I'm definitely still experiencing this issue. I updated to 0.17.8 yesterday.

Version:          Code 1.25.1 (1dfc5e557209371715f655691b1235b6b26a06be, 2018-07-11T15:40:20.190Z)
OS Version:       Linux x64 4.15.0-23-generic
CPUs:             Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz (8 x 2698)
Memory (System):  31.34GB (3.21GB free)
Load (avg):       2, 3, 4
VM:               0%
Screen Reader:    no
Process Argv:     /usr/share/code/code --unity-launch
GPU Status:       2d_canvas:                    enabled
                  flash_3d:                     enabled
                  flash_stage3d:                enabled
                  flash_stage3d_baseline:       enabled
                  gpu_compositing:              enabled
                  multiple_raster_threads:      enabled_on
                  native_gpu_memory_buffers:    disabled_software
                  rasterization:                disabled_software
                  video_decode:                 unavailable_software
                  video_encode:                 enabled
                  vpx_decode:                   unavailable_software
                  webgl:                        enabled
                  webgl2:                       enabled
CPU %   Mem MB     PID  Process
    0       96   25929  code main
    0        0   25931     zygote
    0      257   25970       window (● MistObjectSimulator.cc - werkstatt - Visual Studio Code)
    0      160   26028         extensionHost
    0        0   26095           nvim -u NONE -N --embed
    0     1380   26102           /home/john/.vscode/extensions/ms-vscode.cpptools-0.17.8-insiders/bin/Microsoft.VSCode.CPP.Extension.linux
    0      706   26185             /home/john/.vscode/extensions/ms-vscode.cpptools-0.17.8-insiders/bin/Microsoft.VSCode.CPP.IntelliSense.Msvc.linux 26102 0
    0        0   26459           nvim -u NONE -N --embed
    0        0   26534           nvim -u NONE -N --embed
    0       32   26101         searchService
    0       64   26071       shared-process
    0      128   25960     gpu-process
Workspace Stats:
|  Window (● MistObjectSimulator.cc - werkstatt - Visual Studio Code)
|    Folder (werkstatt): more than 28220 files
|      File types: json(10729) h(4381) hpp(4067) cpp(1944) cc(930) so(866)
|                  1(486) py(237) a(213) sh(196)
|      Conf files: cmake(34) makefile(8) launch.json(6) csproj(6)
|                  package.json(6) tasks.json(4) settings.json(2)
|      Launch Configs: cppdbg(2)

I'm using a compile_commands.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "/usr/include"
            ],
            "intelliSenseMode": "gcc-x64",
            "compileCommands": "${workspaceFolder}/bazel-bin/tools/coverage/compile_commands.json"
        }
    ],
    "version": 4
}

Which the extension seems to read just fine, identifying the correct include paths for this file I just opened:

Attempting to get defaults from compiler found on the machine: '/usr/bin/gcc'
sending compilation args for /home/john/Devel/werkstatt/car/driving/sim/src/MistObjectSimulator.cc
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/common/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/common/geometry/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/platform/fusion/osl/_reaktor_cpp
  include: /home/john/Devel/werkstatt/platform/fusion/include
  include: /home/john/Devel/werkstatt/tools/buildstamp/include
  include: /home/john/Devel/werkstatt/car/config/include
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/config/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/ego/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/driving/ctrl/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/deprecated/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/driving/plan/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/gr_legacy/modular_grid/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/driving/sim/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/driving/sim/scenario_testing/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/environment_model/osl/_reaktor_cpp
  include: /home/john/Devel/werkstatt/car/gr_legacy/common_math/include
  include: /home/john/Devel/werkstatt/car/gr_legacy/common_math/include/common-math
  include: /home/john/Devel/werkstatt/car/gr_legacy/compatibility/include
  include: /home/john/Devel/werkstatt/car/gr_legacy/compatibility/include/adtf_compat
  include: /home/john/Devel/werkstatt/car/gr_legacy/gr_gateway/mapping/include
  include: /home/john/Devel/werkstatt/car/gr_legacy/interfaces/cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/external/rti_connext_dds_pc_linux_amd64_gcc/include
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/external/rti_connext_dds_pc_linux_amd64_gcc/include/ndds
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/external/rti_connext_dds_pc_linux_amd64_gcc/include/ndds/hpp
  include: /home/john/Devel/werkstatt/car/gr_legacy/modular_grid/include
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/external/lz4/lib
  include: /home/john/Devel/werkstatt/car/gr_legacy/prediction_output/include
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/external/eigen
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/gr_legacy/prediction_output/osl/_reaktor_cpp
  include: /home/john/Devel/werkstatt/car/vehicle/include
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/vehicle/osl/_reaktor_cpp
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/genfiles/car/gr_legacy/roadgraph/interfaces/osl/_reaktor_cpp
  include: /home/john/Devel/werkstatt/car/gr_legacy/roadgraph/roadgraph_server
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/bin/car/gr_legacy/roadgraph/roadgraph_server
  include: /home/john/Devel/werkstatt/car/gr_legacy/roadgraph/roadgraph_loader
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/bin/car/gr_legacy/roadgraph/roadgraph_loader
  include: /home/john/Devel/werkstatt/car/gr_legacy/roadgraph/roadgraph_v2/include
  include: /home/john/Devel/werkstatt/car/gr_legacy/roadgraph/interfaces/include
  include: /home/john/Devel/werkstatt/car/gr_legacy/mlbevo_objectlist/include
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/external/boost
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/bin/external/boost
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/bin/car/driving/plan/_virtual_includes/plan
  include: /home/john/.cache/bazel/_bazel_john/b74fab4f1d4785d9b546125b63063446/execroot/werkstatt/bazel-out/k8-dbg/bin/car/driving/plan/cuda_common/_virtual_includes/cuda_common
  include: /usr/include/c++/7
  include: /usr/include/x86_64-linux-gnu/c++/7
  include: /usr/include/c++/7/backward
  include: /usr/lib/gcc/x86_64-linux-gnu/7/include
  include: /usr/local/include
  include: /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
  include: /usr/include/x86_64-linux-gnu
  include: /usr/include

However I also get a ton of debug messages about parsing files from my home folder and elsewhere on the system that have nothing to do with this project and are not in the include paths:

tag parsing file: /home/john/Qt/5.11.1/Src/qtwayland/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp
tag parsing file: /home/john/Qt/5.10.1/Src/qtscript/src/script/api/qscriptprogram.cpp
tag parsing file: home/john/Devel/UnrealEngine/Engine/Source/ThirdParty/OpenSSL/1.0.1g/include/ssl3.h
sean-mcmanus commented 6 years ago

@jondo2010 We need more info -- when you open the workspace what folders does it list as "Folder: … will be indexed"? Those are the folders which we "tag parsed"...typically the files under the workspace root. What is your workspaceRoot -- /home/john? We have a bug where the browse.path is not populated correctly when compile_commands.json was used, but this seems like the opposite of that. My guess is that the workspaceRoot is being forced into the browse.path (intentionally)...you could try adding ${workspaceRoot}/ to the browse.path setting in c_cpp_properties.json to prevent this ( means non-recursive). Also, do you know if this is a 0.17.8-insiders regression compared to 0.17.7? I don't remember us touching this area of code for 0.17.8-insiders.

jondo2010 commented 6 years ago

@sean-mcmanus thanks for the prompt reply.

  Folder: /usr/lib/gcc/x86_64-linux-gnu/7/include/ will be indexed
  Folder: /usr/local/include/ will be indexed
  Folder: /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/ will be indexed
  Folder: /usr/include/ will be indexed
  Folder: /home/john/Devel/werkstatt/ will be indexed

Upon further inspection of the logs, I think the problem is that Bazel has symlinked some root folders into my workspace.. I added the culprits to my "files.exclude", hopefully that fixes it!

jondo2010 commented 6 years ago

Ok, running 0.18.1 now.

My workspace folder contains a symbolic link (${workspaceRoot}/bazel-werkstatt/external/local_files) which resolves to root folders on my disk, /usr/share, /usr/src, etc.

I have tried several permutations of files.exclude:

files.exclude: {
    "/usr/src/**": true,
    "/usr/share/**": true,
    "${workspaceRoot}/bazel-werkstatt/external/local_files/**": true,
}

Intellisense is completely ignorning this and still indexing my entire disk. I can confirm this with the debug console, as well as checking the files table in .browse.VC.db

If I rm this symbolic link, then reset the database, everything behaves correctly.

To reproduce, should be as simple as creating a symlink in your workspace folder to /usr/share or some such, then adding an files.exclude entry.

sean-mcmanus commented 3 years ago

We believe this is fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.3.0-insiders5 , but we don't correctly handle files.exlude with "/**" at the end (removing the "/**" should fix that).

sean-mcmanus commented 3 years ago

I have a fix for the /** at the end of files.exclude for our next-next release: https://github.com/microsoft/vscode-cpptools/issues/7331

mrx23dot commented 2 months ago

So, everything is fixed in this issue? Can we close it?