Skip to content

Commit

Permalink
Rollup merge of rust-lang#98895 - ChrisDenton:no-elves-allowed, r=jyn514
Browse files Browse the repository at this point in the history
bootstrap.py: Always use `.exe` for Windows

This ensures that it will run the Windows executable if other files in the directory (such as Linux executables) have the same file name minus the extension. I've been tripped up by this a few times where both `bootstrap` and `bootstrap.exe` end up in the same directory.

This PR avoids ever having to see the following message:

`OSError: [WinError 193] %1 is not a valid Win32 application`
  • Loading branch information
Dylan-DPC authored Jul 5, 2022
2 parents d2c55ca + 9ac4a4e commit 18e4a05
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs):
if verbose:
print("running: " + ' '.join(args))
sys.stdout.flush()
# Ensure that the .exe is used on Windows just in case a Linux ELF has been
# compiled in the same directory.
if os.name == 'nt' and not args[0].endswith('.exe'):
args[0] += '.exe'
# Use Popen here instead of call() as it apparently allows powershell on
# Windows to not lock up waiting for input presumably.
ret = subprocess.Popen(args, **kwargs)
Expand Down

0 comments on commit 18e4a05

Please sign in to comment.