Windows: Fix arch detection via VCTOOLSINSTALLDIR
if not first in PATH
#93589
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trying to invoke
scons
on Windows withVCTOOLSINSTALLDIR
set (as is the case in the default VS / GDK command prompts) resulted in the following error for me:Turns out we have this piece of code in the Windows platform detect.py, trying to determine the
arch
:godot/platform/windows/detect.py
Lines 141 to 146 in 6b281c0
Here is what this tries to do:
VCTOOLSINSTALLDIR
is set(which for me has a value like
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\
).BIN\HOST
to that value and searches for it inPATH
and if found, saves the starting index of that inPATH
.C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64
inPATH
; it now tries to extract the arch bit in...\Hostx64\...
(x64
).However, there are 2 errors here:
PATH
.os.getenv("PATH").split(";")[0]
just gets the first element ofPATH
, then.rsplit("\\", 1)[-1]
cuts parts of. For me, this resulted in a value ofbin
instead ofx64
, asVCTOOLSINSTALLDIR
was not the first inPATH
. Changing it toos.getenv("PATH")[host_path_index:]...
to actually start at the found index fixes this and resolves the error.if first_path_arch in msvc_target_aliases.keys()
, which would at least have prevented this error.This seems to have been introduced in #64921.