Prevent path-pollution from vpython3.bat

vpython3.bat adds an entry to the path. Unfortunately that modification
persists after the batch file returns. Repeated running of vpython3.bat
will eventually grow the path so long that the command to update the
path exceeds the 8191 character cmd.exe command-length limit. This can
most easily be seen by repeatedly running this command:

    vpython3 -c "print('Hello world!')" && set path | wc

After about 35 invocations (dependent on exact system setup) this
happens:

    >vpython3 -c "print('Hello world!')" && set path | wc
    The input line is too long.
    The syntax of the command is incorrect.

This batch also (but less critically) leaks the PYTHON3_BIN_RELDIR
environment variable.

The fix is to add a setlocal command to keep environment changes local.

Bug: 1003139
Change-Id: I11a31e1013017da702299bfe8eb4888985c228f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3566378
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Brian Ryner <bryner@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
changes/78/3566378/4
Bruce Dawson 3 years ago committed by LUCI CQ
parent a9c548efd6
commit c4b1b772bc

@ -5,6 +5,7 @@
:: TODO(crbug.com/1003139): Remove.
:: Add Python 3 to PATH to work around crbug.com/1003139.
setlocal
for /f %%i in (%~dp0python3_bin_reldir.txt) do set PYTHON3_BIN_RELDIR=%%i
set PATH=%~dp0%PYTHON3_BIN_RELDIR%;%~dp0%PYTHON3_BIN_RELDIR%\Scripts;%~dp0%PYTHON3_BIN_RELDIR%\DLLs;%PATH%

Loading…
Cancel
Save