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

node-gyp gets confused by MSBuild on the %PATH% #1653

Closed
twoi opened this issue Jan 22, 2019 · 3 comments
Closed

node-gyp gets confused by MSBuild on the %PATH% #1653

twoi opened this issue Jan 22, 2019 · 3 comments

Comments

@twoi
Copy link

twoi commented Jan 22, 2019

  • Node-gyp Version: v3.8.0
  • Node Version: v11.7.0
  • Npm Version: 6.5.0
  • Platform: Windows 8.1 Enterprise / 6.3.9600 N/A ビルド 9600 / x64-based PC

I tried to build build a simple module on msvs 2017, but that failed as long as an old MSBuild
c:\Program Files (x86)\MSBuild\14.0\Bin\amd64
was on the %PATH%

When I removed the path, node-gyp build built just fine. It also worked, when I added the latest MSBuild to the %PATH%
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64

So node-gyp configure doesn't seem to care if there is an MSBuild.exe on the path, but node-gyp build stumbles upon an insufficient MSBuild on the path, although it does work fine if there is none at all on the path.

As this took me hours to figure out, I would suggest node-gyp build just ignore any MSBuild on the path. (Otherwise, what's the point of node-gyp configure going to great pains to find a suitable MSBuild in the first place?)

Judging from stackoverflow and github issues, i'm not the only one stumbling on this. In fact, several other developers had "success" after uninstalling (!!) their old Visual Studios - I'm assuming what cured it was that the uninstall also fixed their %PATH%.

Verbose output:
C:\Projects\node>node-gyp configure --verbose --target=v0.12.18 --msvs_version=2017
[...]
gyp verb find vs2017 Found installation at: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.Windows10SDK.14393
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.Windows10SDK.17763
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.VC.Tools.x86.x64
gyp verb find vs2017   - Found Microsoft.VisualStudio.VC.MSBuild.Base
gyp verb find vs2017   - Using this installation with Windows 10 SDK
gyp verb find vs2017 using installation: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise
[...]
gyp info ok

C:\Projects\node>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@11.7.0 | win32 | x64
gyp info spawn msbuild
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
このソリューション内のプロジェクトを 1 度に 1 つずつビルドします。並行ビルドを有効にするには、"/m" スイッチを追加してください。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build us
ing the v141 build tools, please install v141 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and
then selecting "Retarget solution". [C:\Projects\node\build\addon.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:188:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\Projects\node
gyp ERR! node -v v11.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
bzoz added a commit to JaneaSystems/node-gyp that referenced this issue Jan 22, 2019
If node-gyp configure has set up MSBuild location use it instead the
one that happens to be first on the PATH.

Fixes: nodejs#1653
@bzoz
Copy link
Contributor

bzoz commented Jan 22, 2019

Hey @twoi, thanks for your report!

You are absolutely right, MSBuild from the "configure" stage will get used only if no MSBuild is in the %PATH%. PR with a fix in #1654

@twoi
Copy link
Author

twoi commented Jan 23, 2019

That was instantaneous, @bzoz ... Awesome!

refack pushed a commit that referenced this issue Feb 13, 2019
If node-gyp configure has set up MSBuild location use it instead the
one that happens to be first on the PATH.

PR-URL: #1654
Fixes: #1653
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
refack pushed a commit to refack/node-gyp that referenced this issue Feb 13, 2019
If node-gyp configure has set up MSBuild location use it instead the
one that happens to be first on the PATH.

PR-URL: nodejs#1654
Fixes: nodejs#1653
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
@twoi
Copy link
Author

twoi commented Feb 14, 2019

In the meantime, I've switched over to using cmake-js, but thanks nonetheless for addressing the issue this quickly!

rvagg pushed a commit that referenced this issue Apr 24, 2019
If node-gyp configure has set up MSBuild location use it instead the
one that happens to be first on the PATH.

PR-URL: #1654
Fixes: #1653
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants