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

vcbuild changes current directory and fails to find python #14300

Closed
seishun opened this issue Jul 16, 2017 · 7 comments
Closed

vcbuild changes current directory and fails to find python #14300

seishun opened this issue Jul 16, 2017 · 7 comments
Labels
build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform.

Comments

@seishun
Copy link
Contributor

seishun commented Jul 16, 2017

  • Version: master
  • Platform: Windows 10 64-bit
  • Subsystem: build
C:\Users\Nikolai\Downloads\node>python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z


C:\Users\Nikolai\Downloads\node>vcbuild
Looking for Visual Studio 2017
calling: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\\Auxiliary\Build\vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0.26430.14
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Found MSVS version 15.0
The system cannot find the path specified.
Could not find python2
Failed to create vc project files.

C:\Users\Nikolai\Source>

cc @refack

@seishun
Copy link
Contributor Author

seishun commented Jul 16, 2017

Added some echo %cd% in vcbuild.bat, apparently calling vcvarsall changes the current directory:

echo calling: %vcvars_call%
echo %cd%
call %vcvars_call%
echo %cd%
calling: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\\Auxiliary\Build\vcvarsall.bat" amd64
C:\Users\Nikolai\Downloads\node
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0.26430.14
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
C:\Users\Nikolai\Source

Why would that happen?

@refack
Copy link
Contributor

refack commented Jul 16, 2017

Funny I was just discussing this with @gibfahn...

  • The 3rd line in vcbuild.bat is cd %~dp0 so that's probably the cause of changing directory ohh vcvarsall.bat is changing your cd, that is strange, check the %ERRORLEVEL%, maybe it's failing.
  • Check what tools/msvs/find_python.cmd is doing with set DEBUG_HELPER=1.
    Maybe your python is not an .exe but .bat? (find_python.cmd#42)

@refack
Copy link
Contributor

refack commented Jul 16, 2017

Maybe also try to run "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" and do a Repair or Update

@seishun
Copy link
Contributor Author

seishun commented Jul 16, 2017

vcvarsall.bat is changing your cd, that is strange, check the %ERRORLEVEL%, maybe it's failing.

C:\Users\Nikolai\Source>echo %ERRORLEVEL%
1

Check what tools/msvs/find_python.cmd is doing with set DEBUG_HELPER=1.

find_python.cmd doesn't even run because the current directory is wrong. Thus the "The system cannot find the path specified." line.

Maybe also try to run "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" and do a Repair or Update

I could do that, but vcbuild shouldn't fail in such an obscure way because of a broken VS installation.

@refack
Copy link
Contributor

refack commented Jul 16, 2017

Sorry it's my ideas are coming in drips...
You can also see what vcvarsall.bat is doing with set VSCMD_DEBUG=3 (it has several levels I think 3 is the highest)

@refack
Copy link
Contributor

refack commented Jul 16, 2017

I could do that, but vcbuild shouldn't fail in such an obscure way because of a broken VS installation.

Ack. So now we have a bug 👍

@seishun
Copy link
Contributor Author

seishun commented Jul 16, 2017

Looks like ERRORLEVEL is set to 1 later and vcvarsall.bat is successful:

diff --git a/vcbuild.bat b/vcbuild.bat
index 03cf82565d..f8af97bbe9 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -176,9 +176,11 @@ if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_
 set "VSINSTALLDIR="
 call tools\msvs\vswhere_usability_wrapper.cmd
 if "_%VCINSTALLDIR%_" == "__" goto vs-set-2015
+echo error before calling: %ERRORLEVEL%
 set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
 echo calling: %vcvars_call%
 call %vcvars_call%
+echo error after calling: %ERRORLEVEL%
 if errorlevel 1 goto vs-set-2015
 :found_vs2017
 echo Found MSVS version %VisualStudioVersion%

Output with set VSCMD_DEBUG=3:

C:\Users\Nikolai\Downloads\node>vcbuild
Looking for Visual Studio 2017
error before calling: 0
calling: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\\Auxiliary\Build\vcvarsall.bat" amd64
[DEBUG:vcvarsall.bat] init with arguments 'amd64'
[DEBUG:vcvarsall.bat] inner argument {amd64}
[DEBUG:vcvarsall.bat] Command line parse completed with values:
[DEBUG:vcvarsall.bat] __VCVARSALL_TARGET_ARCH='x64'
[DEBUG:vcvarsall.bat] __VCVARSALL_HOST_ARCH='x64'
[DEBUG:vcvarsall.bat] __VCVARSALL_WINSDK=''
[DEBUG:vcvarsall.bat] __VCVARSALL_STORE=''
[DEBUG:vcvarsall.bat] __VCVARSALL_HELP=''
[DEBUG:vcvarsall.bat] __VCVARSALL_PARSE_ERROR='0'
[DEBUG:VsDevCmd] Writing pre-initialization environment to C:\Users\Nikolai\AppData\Local\Temp\dd_vsdevcmd15_preinit_env.log
[DEBUG:core\vsdevcmd_start] initializing with arguments ''
[DEBUG:core\parse_cmd.bat] initializaing with arguments ''
[DEBUG:parse_cmd] inner argument {-arch, x64}
[DEBUG:parse_cmd] inner argument {-host_arch, x64}
[DEBUG:parse_cmd] -no_ext :
[DEBUG:parse_cmd] -winsdk :
[DEBUG:parse_cmd] -app_platform :
[DEBUG:parse_cmd] -test   :
[DEBUG:parse_cmd] -help   :
[DEBUG:parse_cmd] -arch   : x64
[DEBUG:parse_cmd] -host_arch : x64
[DEBUG:vsdevcmd_start] Parsing results...
[DEBUG:vsdevcmd_start] -clean_env :
[DEBUG:vsdevcmd_start] -test      :
[DEBUG:vsdevcmd_start] -help      :
[DEBUG:vsdevcmd_start] end of script: VS150COMNTOOLS="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\"
[DEBUG:vsdevcmd_start] end of script: VSINSTALLDIR="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\"
[DEBUG:vsdevcmd_start] end of script: DevEnvDir="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\"
[DEBUG:VsDevCmd.bat] check_vernum checking 'Version'
[DEBUG:VsDevCmd.bat] check_vernum checking '15.0.26430.14'
[DEBUG:VsDevCmd.bat] check_vernum checking ''
[DEBUG:VsDevCmd.bat] devenv.exe found. Setting VSCMD_VER='15.0.26430.14'.
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0.26430.14
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[DEBUG:VsDevCmd.bat] -clean_env :
[DEBUG:VsDevCmd.bat] -test :
[DEBUG:VsDevCmd.bat] VS150COMNTOOLS : "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\"
[DEBUG:VsDevCmd.bat] calling "core\dotnet.bat"
[vsdevcmd\core\dotnet.bat] initializing...
[DEBUG:core\dotnet.bat] Adding 64-bit .NET Framework Path
[DEBUG:core\dotnet.bat] Framework Preference: 64bit
[DEBUG:core\dotnet.bat] appending '\' to FrameworkDir.
[DEBUG:core\dotnet.bat] init:COMPLETE
[DEBUG:VsDevCmd.bat] calling "core\msbuild.bat"
[DEBUG:core\msbuild.bat] initializing...
[DEBUG:core\msbuild.bat] init:COMPLETE
[DEBUG:VsDevCmd.bat] calling "core\winsdk.bat"
[DEBUG:winsdk.bat] initializing...
[DEBUG:core\winsdk.bat] init:COMPLETE
[DEBUG:VsDevCmd.bat] calling "ext\netfxsdk.bat"
[DEBUG:ext\netfxsdk.bat] init:COMPLETE
[DEBUG:VsDevCmd.bat] calling "ext\perf_tools.bat"
ERROR: The system was unable to find the specified registry key or value.
[DEBUG:~nx0] after reg query 'HKLM\SOFTWARE', __collection_tools=''
[DEBUG:~nx0] after reg query 'HKLM\SOFTWARE\Wow6432Node', __collection_tools='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\'
[DEBUG:ext\perf_tools.bat] init:COMPLETE
[DEBUG:VsDevCmd.bat] calling "ext\roslyn.bat"
[DEBUG:ext\roslyn.bat] init:COMPLETE
[DEBUG:VsDevCmd.bat] calling "ext\team_explorer.bat"
[DEBUG:ext\team_explorer.bat] init:COMPLETE
[DEBUG:VsDevCmd.bat] calling "ext\testwindow.bat"
[DEBUG:ext\testwindow.bat] init:COMPLETE
[DEBUG:VsDevCmd.bat] calling "ext\vcvars.bat"
[DEBUG:vcvars.bat] Checking architecture { host , tgt } : { x64 , x64 }
[DEBUG:vcvars.bat] Could not add directory to IFCPATH: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\ifc\x64"
[DEBUG:ext\vcvars.bat] init:COMPLETE
[DEBUG:core\vsdevcmd_end] initializing with arguments ''
[DEBUG:VsDevCmd] Writing post-execution environment to C:\Users\Nikolai\AppData\Local\Temp\dd_vsdevcmd15_env.log
[vcvarsall.bat] Environment initialized for: 'x64'
error after calling: 0
Found MSVS version 15.0
The system cannot find the path specified.
Could not find python2
Failed to create vc project files.

@seishun seishun changed the title vcbuild fails to find python and changes current directory vcbuild changes current directory and fails to find python Jul 16, 2017
@mscdex mscdex added build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform. labels Jul 16, 2017
addaleax pushed a commit that referenced this issue Jul 18, 2017
VsDevCmd.bat changes the current working directory to
"%USERPROFILE%\Source" if it exists. Setting VSCMD_START_DIR overrides
this behavior.

PR-URL: #14303
Fixes: #14300
Refs: https://developercommunity.visualstudio.com/content/problem/26780/vsdevcmdbat-changes-the-current-working-directory.html
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Fishrock123 pushed a commit that referenced this issue Jul 19, 2017
VsDevCmd.bat changes the current working directory to
"%USERPROFILE%\Source" if it exists. Setting VSCMD_START_DIR overrides
this behavior.

PR-URL: #14303
Fixes: #14300
Refs: https://developercommunity.visualstudio.com/content/problem/26780/vsdevcmdbat-changes-the-current-working-directory.html
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants