Skip to content

Commit df7bf1c

Browse files
committed
gh: fix native-cmd PATH-truncation regression check
The padding added to reproduce a large pre-existing PATH appended onto the runner's own already large inherited PATH instead of replacing it, pushing the total past the 8191-character command line length limit of cmd.exe and making INSTALL.bat fail outright with "The input line is too long" before it even reached the code this check is meant to exercise. Replace the PATH instead of extending it, keeping its length controlled and safely between the two limits. Also drop the bin-directory-in-persisted-PATH check added to TESTINSTALL.bat: that script is also invoked, to test the cmd shell environment, by TESTINSTALL_PWSH.ps1 after INSTALL_PWSH.bat, which intentionally never touches the system PATH, so the check does not hold there. Move it into the native-cmd job's dedicated verification step instead, where it is only asserted after the plain INSTALL.bat flow that is supposed to persist it. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
1 parent d27c45e commit df7bf1c

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ doc/talk export-ignore
2727
# flag the CR as a trailing whitespace error
2828
script/INSTALL.bat whitespace=cr-at-eol
2929
script/UNINSTALL.bat whitespace=cr-at-eol
30-
script/TESTINSTALL.bat whitespace=cr-at-eol

.github/workflows/windows_tests.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,31 @@ jobs:
4848
run: |
4949
jar xvf %DIST_WIN%.zip
5050
cd %DIST_WIN%
51-
:: simulate a large pre-existing PATH, such as found in a Visual
52-
:: Studio Developer Prompt, to exercise persisting a system PATH
53-
:: beyond the legacy 1024-character limit of the 'setx' tool
54-
:: previously used here (see GH-654)
51+
:: replace (rather than extend) the inherited PATH with a
52+
:: controlled value that is still past the legacy 1024-character
53+
:: limit of the 'setx' tool previously used here, to simulate a
54+
:: large pre-existing PATH such as found in a Visual Studio
55+
:: Developer Prompt (see GH-654), while staying safely under the
56+
:: 8191-character command line length limit of cmd.exe
5557
setlocal enabledelayedexpansion
56-
for /L %%i in (1,1,60) do set "PATH=!PATH!;C:\dummy-path-segment-%%i"
58+
set "PATH=%SYSTEMROOT%\system32;%SYSTEMROOT%"
59+
for /L %%i in (1,1,50) do set "PATH=!PATH!;C:\dummy-path-segment-%%i"
5760
set "PATH=!PATH!;C:\marker-end-of-long-path"
5861
call INSTALL.bat
5962
- name: Check persisted PATH is not truncated
6063
shell: cmd
6164
run: |
62-
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PATH | %SYSTEMROOT%\system32\find /i "marker-end-of-long-path" >nul
65+
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PATH > persisted-path.txt
66+
%SYSTEMROOT%\system32\find /i "marker-end-of-long-path" persisted-path.txt >nul
6367
if errorlevel 1 (
6468
echo "persisted system PATH truncated: marker entry not found"
6569
exit /b 1
6670
)
71+
%SYSTEMROOT%\system32\find /i "%MODULE_DIR%" persisted-path.txt >nul
72+
if errorlevel 1 (
73+
echo "installation 'bin' directory not found in persisted system PATH"
74+
exit /b 1
75+
)
6776
- name: Test Modules installation
6877
shell: cmd
6978
run: |

script/TESTINSTALL.bat

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ if not defined MODULES_CMD (
1414

1515
set FIND=%SYSTEMROOT%\system32\find
1616

17-
:: check installation 'bin' directory is found in persisted system PATH
18-
:: (current session PATH is not relevant here as it may have been set
19-
:: independently of what got written to the registry by INSTALL.bat)
20-
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PATH | %FIND% /i "%installpath%\bin" >nul
21-
if errorlevel 1 (
22-
echo "installation 'bin' directory not found in persisted system PATH"
23-
exit /b 1
24-
)
25-
2617
:: check commands exist
2718
where /Q module.cmd
2819
if errorlevel 1 (

0 commit comments

Comments
 (0)