Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Users with insufficiently configured Visual Studio 2015 (or older) installs are prevented from using a working Visual Studio 2017 or 2019 #893

Closed
1 task
DeeDeeG opened this issue Jul 15, 2020 · 0 comments · Fixed by #892 or atom-community/apm#2

Comments

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Jul 15, 2020

Prerequisites

Description

apm can't detect Visual Studio/Build Tools 2017 or newer.

If a Windows user has a non-usable Visual Studio 2015 or earlier installed (for example, if Visual Studio is installed, but no C++ Build Tools, or no Windows 8/10 SDK is installed), apm will still detect and prefer the non-working, older version.

Steps to Reproduce

  1. Install Visual Studio 2017 or newer with all the required components (such as C++ Build Tools, C++ Core Tools, and a Windows 8 or Windows 10 SDK). This is a usable install of Visual Studio.
  2. Install Visual Studio 2015 or earlier, but don't install C++ Build Tools, or don't install the a Windows 8/10 SDK component. This is a non-usable install of Visual Studio.
  3. Install Atom and apm.
  4. Try to install a package that requires native code to be built. e.g. apm install tree-view.

Expected behavior:

apm install should work using the usable Visual Studio 2017 or 2019 install.

Actual behavior:

apm install fails, with an error about not finding a usable version of Visual Studio, but that other versions would have been valid if set by the flag (this will be "2017" or "2019").

Reproduces how often:

100% of the time, given the conditions laid out in "steps to reproduce" are met.

Versions

C:\Users\[User]>atom-dev --version

 Atom    : 1.50.0-dev-9c16e5c67
Electron: 6.1.12
Chrome  : 76.0.3809.146
Node    : 12.4.0

C:\Users\[User]>apm-dev --version
apm  2.5.0
npm  6.14.5
node 10.20.1 x64
atom 1.50.0-dev-9c16e5c67
python 2.7.18
git 2.27.0.windows.1
visual studio

Happens with apm 2.5.0, or from master branch of this repository. apm has never supported Visual Studio 2017 or 2019, because its hard-coded list of versions to detect only goes up to Visual Studio 2015:

https://github.com/atom/apm/blob/v2.5.0/src/apm.coffee#L82-L91

Additional Information

I have a fix for this, posted at PR #892.

Here's what is happening "under the hood", so to speak:

apm install specifies --msvs_version = [some older Visual Studio version such as 2015] when running node-gyp.

https://github.com/atom/apm/blob/v2.5.0/src/apm.coffee#L82-L91

If this version of Visual Studio is missing some required components, node-gyp then rejects that version. Node-gyp fails to find a usable Visual Studio version matching the version set by the --msvs_version flag, and errors out.

Node-gyp itself is better at figuring out whether a Visual Studio version is installed, and whether it has adequate components installed to build native code. So in my view, we should just let node-gyp handle this and not pass the --msvs_version flag at all to node-gyp.

We can still attempt to detect Visual Studio on the disk for the sake of printing it during apm --version. But that is the only reason we should try to detect which version is installed, and the only thing we should use that version number for is printing it during apm --version. Otherwise, for the higher-stakes task of picking a Visual Studio install to build code with, we should let node-gyp do it.

@DeeDeeG DeeDeeG changed the title apm install fails if a misconfigured (non-usable) Visual Studio 2015 or older is installed, even if a usable Visual Studio 2017 or 2019 is installed Users with insufficiently configured Visual Studio 2015/older installs are prevented from using a working Visual Studio 2017 or 2019. Jul 17, 2020
@DeeDeeG DeeDeeG changed the title Users with insufficiently configured Visual Studio 2015/older installs are prevented from using a working Visual Studio 2017 or 2019. Users with insufficiently configured Visual Studio 2015 (or older) installs are prevented from using a working Visual Studio 2017 or 2019 Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant