microsoft / vscode-cpptools

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

How do I fix this problem: "Unable to start the C/C++ language server. IntelliSense features will be disabled. Error: Error: EPERM: operation not permitted, scandir " #11752

Open travelling-clouds opened 10 months ago

travelling-clouds commented 10 months ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: I can't start C/C++ language server when I update extension C/C++.

Steps to reproduce:

  1. Go to 'Extensions'
  2. Update extension C/C++. Notes: I can use C/C++ language server before updating. The version was 1.16.3 before.
  3. Reload VS Code.
  4. See error: Unable to start the C/C++ language server. IntelliSense features will be disabled. Error: Error: EPERM: operation not permitted, scandir 'f:/System Volume Information' Just Like: image

Expected behavior: I hope to solve this problem/bug. I tried on other machines but the same problem arose.

Configuration and Logs

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "D:\\Program Files\\Microsoft Visual Studio\\IDE\\VC\\Tools\\MSVC\\**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "D:/Program Files/Microsoft Visual Studio/IDE/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "windows-msvc-x64"
        },
        {
            "name": "c++",
            "includePath": [
                "${workspaceFolder}/**",
                "D:/Program Files/GCC/mingw32/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "D:/Program Files/GCC/mingw32/bin/c++.exe",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "windows-gcc-x64"
        },
        {
            "name": "g++",
            "includePath": [
                "${workspaceFolder}/**",
                "D:/Program Files/Dev-Cpp/MinGW32/**",
                "D:/Program Files/Dev-Cpp/MinGW32/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "D:/Program Files/GCC/mingw32/bin/g++.exe",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "windows-gcc-x64"
        },
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

the language server logging:

loggingLevel: Debug
LSP: (received) cpptools/initialize (id: 1)
LSP: (invoked) cpptools/initialize (id: 1)
cpptools version (TypeScript): 1.18.5
cpptools version (native): 1.18.3.0
Autocomplete is enabled.
Error squiggles are enabled.
Hover is enabled.
IntelliSense Engine = default.
LSP: Message ignored due to no registered handler: $/setTrace
LSP: (received) cpptools/queryCompilerDefaults (id: 2)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 2)
LSP: (received - deferred) textDocument/didOpen: file:///f%3A/C%2B%2B/Code/C%2B%2B-GUI/Win32%20APP/Controls/main.cpp
Querying compiler for default C++ language standard using command line: "D:/Program Files/GCC/mingw32/bin/g++.exe" -x c++ -E -dM nul
LSP: (received) cpptools/didChangeSettings
LSP: (received) cpptools/didChangeSettings
LSP: (received - deferred) cpptools/activeDocumentChange: file:///f%3A/C%2B%2B/Code/C%2B%2B-GUI/Win32%20APP/Controls/main.cpp
LSP: (received - deferred) cpptools/textEditorSelectionChange
LSP: (received - deferred) cpptools/getCodeActions: file:///f%3A/C%2B%2B/Code/C%2B%2B-GUI/Win32%20APP/Controls/main.cpp (id: 3)
Detected language standard version: gnu++14
Querying compiler's default target using command line: "D:/Program Files/GCC/mingw32/bin/g++.exe" -dumpmachine
Compiler returned default target value: i686-w64-mingw32
Compiler query command line: "D:/Program Files/GCC/mingw32/bin/g++.exe" -std=c17 -m32 -Wp,-v -E -dM -x c nul
LSP: $/cancelRequest (cpptools/getCodeActions, id: 3)
LSP: (received - deferred) cpptools/getCodeActions: file:///f%3A/C%2B%2B/Code/C%2B%2B-GUI/Win32%20APP/Controls/main.cpp (id: 4)
LSP: $/cancelRequest (cpptools/getCodeActions, id: 4)
LSP: (received - deferred) cpptools/getCodeActions: file:///f%3A/C%2B%2B/Code/C%2B%2B-GUI/Win32%20APP/Controls/main.cpp (id: 5)
LSP: $/cancelRequest (cpptools/getCodeActions, id: 5)
LSP: (received - deferred) cpptools/getCodeActions: file:///f%3A/C%2B%2B/Code/C%2B%2B-GUI/Win32%20APP/Controls/main.cpp (id: 6)
Attempting to get defaults from C compiler in "compilerPath" property: 'D:/Program Files/GCC/mingw32/bin/g++.exe'
Compiler query command line: "D:/Program Files/GCC/mingw32/bin/g++.exe" -std=gnu++14 -m32 -Wp,-v -E -dM -x c++ nul
Attempting to get defaults from C++ compiler in "compilerPath" property: 'D:/Program Files/GCC/mingw32/bin/g++.exe'
LSP: (invoked) cpptools/didChangeSettings
Autocomplete is enabled.
Error squiggles are enabled.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: (invoked) cpptools/didChangeSettings
Autocomplete is enabled.
Error squiggles are enabled.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: Message ignored due to no registered handler: $/setTrace
LSP: (received) cpptools/didChangeSettings
LSP: (invoked) cpptools/didChangeSettings
Autocomplete is enabled.
Error squiggles are enabled.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: Message ignored due to no registered handler: $/setTrace
LSP: (received) cpptools/didChangeSettings
LSP: (invoked) cpptools/didChangeSettings
Autocomplete is enabled.
Error squiggles are enabled.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: $/cancelRequest (cpptools/getCodeActions, id: 6)
LSP: (received - deferred) cpptools/getCodeActions: file:///f%3A/C%2B%2B/Code/C%2B%2B-GUI/Win32%20APP/Controls/main.cpp (id: 7)
LSP: $/cancelRequest (cpptools/getCodeActions, id: 7)
LSP: (received - deferred) cpptools/getCodeActions: file:///f%3A/C%2B%2B/Code/C%2B%2B-GUI/Win32%20APP/Controls/main.cpp (id: 8)
LSP: (received - deferred) cpptools/activeDocumentChange: file:///f%3A/C%2B%2B/Code/C%2B%2B-GUI/Win32%20APP/Controls/main.cpp
LSP: (received - deferred) cpptools/textEditorSelectionChange

Other Extensions

You can see what extensions I installed in the image below. image image image I tried to disable other extensions except C/C++, C/C++ Extension Pack, but the problem still arose.

Additional context

No response

browntarik commented 10 months ago

Thank you for submitting this issue. It looks like the extension is attempting to look inside of the system volume information folder with an unelevated user won't have access too. As a workaround, consider opening the folder on another disk or location on your machine. Currently looking into this further.

bobbrow commented 10 months ago

I'm pretty sure that looking into the System Volume Information folder is unintentional. Is your workspace on the F: drive? Does it have any symlinks in it?

Also, in all of your configurations, can you also please remove the paths to the standard headers from the includePath setting? Just change them back to "includePath": [ "${workspaceFolder}/**" ]. When you set a compilerPath we discover the paths to the standard headers automatically, and adding them manually can mess up the include ordering that your program expects.

travelling-clouds commented 10 months ago

I'm pretty sure that looking into the System Volume Information folder is unintentional. Is your workspace on the F: drive? Does it have any symlinks in it?

Also, in all of your configurations, can you also please remove the paths to the standard headers from the includePath setting? Just change them back to "includePath": [ "${workspaceFolder}/**" ]. When you set a compilerPath we discover the paths to the standard headers automatically, and adding them manually can mess up the include ordering that your program expects.

Thank you. I've done what you say. And I think that I've found out the problem. I have 2 operation systems on my laptop, one is Windows, the other is Ubuntu Linux. So, there is a configuration for Linux. I did the tests like the video below. Notes: I did these tests after updating VS Code to the newest version 1.85. Tests That's strange, and the settings of "name": "Linux", includePath": [ "${workspaceFolder}/**", "/usr**" ] was added to my configuration automatically. And I think that the configuration for Linux will not affect my operations on Windows. Now my c_cpp_properties.json is like this:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "D:\\Program Files\\Microsoft Visual Studio\\IDE\\VC\\Tools\\MSVC\\**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "D:/Program Files/Microsoft Visual Studio/IDE/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "windows-msvc-x64"
        },
        {
            "name": "c++",
            "includePath": [
                "${workspaceFolder}/**",
                "D:/Program Files/GCC/mingw32/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "D:/Program Files/GCC/mingw32/bin/c++.exe",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "windows-gcc-x64"
        },
        {
            "name": "g++",
            "includePath": [
                "${workspaceFolder}/**",
                "D:/Program Files/GCC/mingw32/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "D:/Program Files/GCC/mingw32/bin/g++.exe",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "windows-gcc-x64"
        },
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}