Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration - cl.exe installed with 'Build Tools for Visual Studio' not detected #4929

Closed
pedro-w opened this issue Feb 6, 2020 · 12 comments
Assignees
Labels
bug Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@pedro-w
Copy link

pedro-w commented Feb 6, 2020

I am following the instructions in https://code.visualstudio.com/docs/cpp/config-msvc
When I get to step 2, in the Compiler Path box I see a red "(No compiler paths detected)"
From the command prompt, cl.exe is definitely on the path.
I can set it manually in the c_cpp_properties.json - should be C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64 - but the docs imply that the extension should be able to pick this up automatically.

VS Code version: 1.41.1
C/C++ extension version: 0.26.3
Compilers: Visual Studio 2019 Developer Command Prompt v16.4.4
(not installed Visual Studio, just the command line tools)

@Colengms
Copy link
Collaborator

Colengms commented Feb 6, 2020

Hi @pedro-w . It looks like you are using "Build Tools for Visual Studio 2019", and do not have Visual Studio 2019 (Preview) installed. Is that correct? If so, it looks like we may not be detecting the install location for Build Tools correctly.

@Colengms Colengms added bug Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service labels Feb 6, 2020
@Colengms Colengms added this to the 1.0.0 milestone Feb 6, 2020
@Colengms Colengms changed the title Configuration - not able to find compiler without help Configuration - cl.exe installed with 'Build Tools for Visual Studio' not detected Feb 6, 2020
@pedro-w
Copy link
Author

pedro-w commented Feb 6, 2020

@Colengms yes, correct, it was "Build Tools for Visual Studio 2019" from https://visualstudio.microsoft.com/downloads/#other

@pedro-w
Copy link
Author

pedro-w commented Feb 12, 2020

I was trying to see if I could help diagnose the cause myself but I can't find where in the code it actually looks for the compilers. I assume it's something to do with the knownCompilers property?
I have downloaded the latest code from this repo and am able to rebuild/debug it in VS code. Any hints as to where to start?

@sean-mcmanus
Copy link
Collaborator

Yeah, if you don't see the build tools for VS in the knownCompilers, then it's not being found by our closed source language server component.

@pedro-w
Copy link
Author

pedro-w commented Feb 12, 2020

I thought I was losing my marbles when I couldn't find the code for setting knownCompilers! Anyway please let me know if I can provide any more info to help.

@Colengms
Copy link
Collaborator

Hi @pedro-w . I'm having trouble repro'ing this. I created a fresh VM (without VS), installed the VS 2019 Build Tools (with C++ Build Tools checked), opened a new folder in VS Code (with no c_cpp_properties.json), opened a .cpp file to trigger the C++ Extension (v0.26.3) to start up. Then I ran the command C/C++: Edit Configuration (JSON), and saw that it populated a newly created c_cpp_properties.json with the proper compiler path. Could you try the above, and see if you get the same results?

Attempting the above and selecting C/C++: Edit Configuration (UI) instead also appeared to populate the correct compiler path.

Compiler detection is done in our native exe. We iterate through all directories found under the following path: %ProgramData%\Microsoft\VisualStudio\Packages\_Instances . Within each of those directories, we open state.json, and look for installationPath. We add \VC\Tools\MSVC to that path, and look for a folder there containing a version number (only '.' and numbers). Within that folder we expect to find folders named "include" and "bin". We expect to find bin/Hostx64/x64/cl.exe and/or bin/Hostx86/x86/cl.exe . Can you confirm whether there is anything that might be blocking any of these steps?

@Colengms Colengms removed this from the 1.0.0 milestone Feb 14, 2020
@Colengms Colengms added the not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). label Feb 14, 2020
@pedro-w
Copy link
Author

pedro-w commented Feb 14, 2020

I'll check the fresh install stuff but it might take me a while to set up a VM etc.

I can say straight away that I don't have the _Instances path that you mentioned. I guess this is the reason why your server can't find the file?

>echo %ProgramData%
C:\ProgramData
>dir %ProgramData%\Microsoft\VisualStudio\Packages\
 Volume in drive C is OS
 Volume Serial Number is 2ABE-6EC2

 Directory of C:\ProgramData\Microsoft\VisualStudio\Packages

14/11/2018  08:57    <DIR>          .
14/11/2018  08:57    <DIR>          ..
06/02/2020  08:52    <DIR>          _bootstrapper
06/02/2020  08:59    <DIR>          _Channels
               0 File(s)              0 bytes
               4 Dir(s)  29,392,039,936 bytes free

I have installed and uninstalled Visual Studio 2019 Community in the past and maybe that has caused some confusion in the configuration.
Anyway if I can get a fresh VM set up that will hopefully point us in the right direction.
Thanks for your help.

@pedro-w
Copy link
Author

pedro-w commented Feb 14, 2020

OK I have made some progress. I installed VS code and the Build tools on a real Windows 10 PC which had never had either on before. Everything worked as you describe. I saw that %ProgramData%\Microsoft\VisualStudio\Packages contained a whole bunch of directories named after packages (I assume) as well as the _Instances directory.

Back on my PC, I found another path on my D: drive (I've got a small SSD C: and a larger HDD D:) which was D:\ProgramData\Microsoft\VisualStudio\Packages and in here I found the _Instances and all the other stuff.

It's quite likely I told the VS installer at some point to put stuff on D:\ because my C:\ drive was getting full.

The VS Installer itself seems to be OK with this (and the tools themselves are actually installed to C:) so I don't know if this is in their remit to change or yours?

Anyway it's not difficult just to set the compiler path manually, though having just gone through the 'automatic' process on a fresh PC, it's really impressive how straightforward you've made it. Thanks!

[edit]
I found this path in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\Setup\CachePath

with the value

D:\ProgramData\Microsoft\VisualStudio\Packages

so maybe you should be looking in there?

@Colengms
Copy link
Collaborator

@pedro-w . Thanks for digging into this. I think you are absolutely correct.

@Colengms Colengms removed the not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). label Feb 20, 2020
@bobbrow bobbrow added this to the 1.0.0 milestone Feb 20, 2020
@bobbrow bobbrow added the fixed Check the Milestone for the release in which the fix is or will be available. label Feb 24, 2020
@sean-mcmanus
Copy link
Collaborator

Fixed in our latest Insiders release: https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders.

@pedro-w
Copy link
Author

pedro-w commented Mar 4, 2020

I have installed the insiders release and am happy to report that the drop-down now contains the correct path to the compiler. I was able to follow the "Configure VS Code for Microsoft C++" article that I mentioned above from beginning to end. Thanks for your help with this!

Quick question - since I also have the MSVC 32-bit compilers and the cross compilers installed, I would have expected them to be in the drop-down too, but only the 64-bit native compiler was listed. Is this what you would expect?

@sean-mcmanus
Copy link
Collaborator

The bitness of the compiler shown doesn't currently have any effect for cl.exe in regards to IntelliSense, which can have its bitness changed via the msvc-x64 or msvc-x86 intelliSenseMode settings.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

4 participants