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

Random failure with error "Command failed: cmd.exe /q /c C:\Users\runneradmin\msvc-dev-cmd.bat" #8

Open
coder3101 opened this issue Jun 1, 2020 · 19 comments · Fixed by #37 or matteobaccan/SockRedirector#35

Comments

@coder3101
Copy link

The action randomly fails with the following log, sometimes

2020-06-01T09:22:32.7166338Z     Merge branch 'github-actions' of https://github.com/BoostGSoC20/ublas into github-actions
2020-06-01T09:22:32.7445679Z ##[group]Run ilammy/[email protected]
2020-06-01T09:22:32.7445841Z with:
2020-06-01T09:22:32.7445928Z   toolset: 14.25
2020-06-01T09:22:32.7446020Z   arch: x64
2020-06-01T09:22:32.7446116Z ##[endgroup]
2020-06-01T09:22:40.4214652Z ##[error]Could not setup Developer Command Prompt: Command failed: cmd.exe /q /c C:\Users\runneradmin\msvc-dev-cmd.bat

Check this Job which failed: https://github.com/BoostGSoC20/ublas/runs/726808960?check_suite_focus=true

Check this job with the same configuration that passed: https://github.com/BoostGSoC20/ublas/runs/726808920?check_suite_focus=true

This failure is completely random. I looked into it and found that in the latest release this action still uses some script but after 5a6b51d, this behaviour changed. Please look into it and if possible you could release a new version with this commit.

@coder3101
Copy link
Author

@ilammy Any update on this. Due to this random error, my CI is completely unresponsive and unreliable.

@ilammy
Copy link
Owner

ilammy commented Jun 14, 2020

Hey, @coder3101! I've just pushed a new v1.3.0 with that batch file change.

I'm still puzzled at what can break there, but could you please try it out?

      - name: Enable Developer Command Prompt
        uses: ilammy/[email protected]

@coder3101
Copy link
Author

Nothing was broken rather what was is the behaviour of this extension if a msvc of a version is requested which is not installed? Say 14.25 on windows-2019 image is no longer present. So I changed it to 14.26 and now it works fine. Maybe instead of just error-ing out the extension should say "this version of msvc does not exist"

@kwhat
Copy link

kwhat commented Jul 9, 2020

Hmm, I am running into this as well. This only happens for me with arch: amd64_arm being run first, followed by arch: amd64 on the same machine after building for arm. Ex:

  windows:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v1
        with:
          submodules: true

      - name: Setup arm
        uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: amd64_arm

      - name: Compile arm
        shell: cmd
        run: |
          cmake -B ${{github.workspace}}\build ^
            -G "Visual Studio 16 2019" -A ARM ^
            -DCMAKE_INSTALL_PREFIX=${{github.workspace}}\dist\arm ^
            -DCMAKE_VERBOSE_MAKEFILE=true ^
            -DUIOHOOK_ENABLE_DEMO=ON -DUIOHOOK_ENABLE_STATIC=ON -DUIOHOOK_ENABLE_SHARED=ON

          cmake --build ${{github.workspace}}\build ^
            --parallel 2 ^
            --config RelWithDebInfo ^
            --clean-first

          cmake --install ${{github.workspace}}\build --config RelWithDebInfo

      - name: Setup x86
        uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: amd64_x86

      - name: Compile x86
        shell: cmd
        run: |
          cmake -B ${{github.workspace}}\build ^
            -G "Visual Studio 16 2019" -A Win32 ^
            -DCMAKE_INSTALL_PREFIX=${{github.workspace}}\dist\x86 ^
            -DCMAKE_VERBOSE_MAKEFILE=true ^
            -DUIOHOOK_ENABLE_DEMO=ON -DUIOHOOK_ENABLE_STATIC=ON -DUIOHOOK_ENABLE_SHARED=ON

          cmake --build ${{github.workspace}}\build ^
            --parallel 2 ^
            --config RelWithDebInfo ^
            --clean-first

          cmake --install ${{github.workspace}}\build --config RelWithDebInfo

      - name: Setup x86_64
        uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: amd64

      - name: Compile x86_64
        shell: cmd
        run: |
          cmake -B ${{github.workspace}}\build ^
            -G "Visual Studio 16 2019" -A x64 ^
            -DCMAKE_INSTALL_PREFIX=${{github.workspace}}\dist\x86_64 ^
            -DCMAKE_VERBOSE_MAKEFILE=true ^
            -DUIOHOOK_ENABLE_DEMO=ON -DUIOHOOK_ENABLE_STATIC=ON -DUIOHOOK_ENABLE_SHARED=ON

          cmake --build ${{github.workspace}}\build ^
            --parallel 2 ^
            --config RelWithDebInfo ^
            --clean-first

          cmake --install ${{github.workspace}}\build --config RelWithDebInfo

This works for arm and x86, then fails to setup amd64.

image
Raw Logs: https://pipelines.actions.githubusercontent.com/KsSXXK5ZRoLLH7Hdn094K6DkfEEdzB3Ku22tDZK5EnfdPpcLY7/_apis/pipelines/1/runs/203/signedlogcontent/7?urlExpires=2020-07-09T04%3A59%3A36.5876834Z&urlSigningMethod=HMACV1&urlSignature=smFooBrhtLdLACQ%2Bsz4dckzeakKrwTy8XLzPsBF17Gk%3D

@kwhat
Copy link

kwhat commented Jul 9, 2020

Seems to only fail after the second usage, order doesn't appear to matter.

@aminya
Copy link
Contributor

aminya commented Sep 21, 2020

I could reproduce this as well.

2020-09-21T11:46:09.5985052Z ##[group]Run ilammy/msvc-dev-cmd@v1
2020-09-21T11:46:09.5985585Z with:
2020-09-21T11:46:09.5985870Z   arch: x64
2020-09-21T11:46:09.5986087Z   sdk: 10.1.19041.1
2020-09-21T11:46:09.5986429Z ##[endgroup]
2020-09-21T11:46:13.4050636Z ##[error]Could not setup Developer Command Prompt: Command failed: cmd.exe /q /c C:\Users\runneradmin\msvc-dev-cmd.bat

@ilammy
Copy link
Owner

ilammy commented Sep 23, 2020

🤔

Does this issue reproduce with v1.3.0?

jobs:
  ...:
    - uses: ilammy/[email protected]

Or maybe it prints more helpful error message if it fails.

Currently v1 points to v1.2.0 which does not contain some improvements.

@aminya
Copy link
Contributor

aminya commented Sep 23, 2020

Could we add a try catch to this line, so we can get more information?

const { stdout } = await exec(command, {shell: "cmd"})

Also, we should use execSync here. Awaiting a promise right away is equal to synchronous execution.

@ilammy
Copy link
Owner

ilammy commented Sep 23, 2020

Could we add a try catch to this line, so we can get more information?

If it throws, the line 111 catches it:

main().catch((e) => core.setFailed('Could not setup Developer Command Prompt: ' + e.message))

And that's the message being printed.

From what I gather from Node.js docs, it should contain more information than just the message, like captured stderr, but I'm not quite sure how to access it.

Also, we should use execSync here. Awaiting a promise right away is equal to synchronous execution.

Makes sense 🤔

@pzhlkj6612
Copy link
Contributor

Hi, @coder3101 .

Say 14.25 on windows-2019 image is no longer present.

Good news: the toolset 14.25 has been back on 1 July 2020. See actions/runner-images#1146 .

@pzhlkj6612
Copy link
Contributor

Hi, @kwhat .

Seems to only fail after the second usage, order doesn't appear to matter.

Thank you for posting the screenshot of the log. Let's focus on these two lines:

The input line is too long.
The syntax of the command is incorrect.

Analysis

Try to find them on Internet:

Does the command line exceed the limit of 8192 characters? We can test it on GitHub Actions or our own computer with MSVC installed:

    runs-on: windows-2019
    steps:
      - shell: cmd
        run: |
          :loop
          echo ======
          call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
          echo ------
          set
          echo ======
          goto loop

Why use call : Sequence of instructions in cmd shell doesn't work - GitHub Actions - GitHub Support Community

In my test, the workflow failed on the third execution of vcvarsall.bat:

...
======
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.9.4
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
------
...
Path=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\;C:\Users\runneradmin\.dotnet\tools;C:\Program Files\MongoDB\Server\4.4\bin;C:\aliyun-cli;C:\vcpkg;C:\cf-cli;C:\Program Files (x86)\NSIS\;C:\tools\zstd;C:\Program Files\Mercurial\;C:\hostedtoolcache\windows\stack\2.5.1\x64;C:\tools\ghc-9.0.1\bin;C:\Program Files\dotnet;C:\mysql-5.7.21-winx64\bin;C:\Program Files\R\R-4.0.5\bin\x64;C:\SeleniumWebDrivers\GeckoDriver;C:\Program Files (x86)\sbt\bin;C:\Rust\.cargo\bin;C:\Program Files (x86)\GitHub CLI;C:\Program Files\Git\bin;C:\Program Files (x86)\pipx_bin;C:\hostedtoolcache\windows\go\1.15.11\x64\bin;C:\hostedtoolcache\windows\Python\3.7.9\x64\Scripts;C:\hostedtoolcache\windows\Python\3.7.9\x64;C:\hostedtoolcache\windows\Ruby\2.5.9\x64\bin;C:\hostedtoolcache\windows\Java_Adopt_jdk\8.0.292-10\x64\bin;C:\npm\prefix;C:\Program Files\Microsoft SDKs\Azure\Azure Dev Spaces CLI;C:\Program Files\Microsoft SDKs\Azure\Azure Dev Spaces CLI\;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\ProgramData\kind;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\Chocolatey\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Docker;C:\Program Files\PowerShell\7\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\lib\pulumi\tools\Pulumi\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\OpenSSL\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;c:\tools\php;C:\Program Files (x86)\sbt\bin;C:\Program Files\TortoiseSVN\bin;C:\SeleniumWebDrivers\ChromeDriver\;C:\SeleniumWebDrivers\EdgeDriver\;C:\Program Files\CMake\bin;C:\Program Files\Amazon\AWSCLIV2\;C:\Program Files\Amazon\SessionManagerPlugin\bin\;C:\Program Files\Amazon\AWSSAMCLI\bin\;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files (x86)\Microsoft BizTalk Server\;C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\x64\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\VC\Linux\bin\ConnectionManagerExe
...
======
======
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.9.4
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
------
...
Path=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\;C:\Users\runneradmin\.dotnet\tools;C:\Program Files\MongoDB\Server\4.4\bin;C:\aliyun-cli;C:\vcpkg;C:\cf-cli;C:\Program Files (x86)\NSIS\;C:\tools\zstd;C:\Program Files\Mercurial\;C:\hostedtoolcache\windows\stack\2.5.1\x64;C:\tools\ghc-9.0.1\bin;C:\Program Files\dotnet;C:\mysql-5.7.21-winx64\bin;C:\Program Files\R\R-4.0.5\bin\x64;C:\SeleniumWebDrivers\GeckoDriver;C:\Program Files (x86)\sbt\bin;C:\Rust\.cargo\bin;C:\Program Files (x86)\GitHub CLI;C:\Program Files\Git\bin;C:\Program Files (x86)\pipx_bin;C:\hostedtoolcache\windows\go\1.15.11\x64\bin;C:\hostedtoolcache\windows\Python\3.7.9\x64\Scripts;C:\hostedtoolcache\windows\Python\3.7.9\x64;C:\hostedtoolcache\windows\Ruby\2.5.9\x64\bin;C:\hostedtoolcache\windows\Java_Adopt_jdk\8.0.292-10\x64\bin;C:\npm\prefix;C:\Program Files\Microsoft SDKs\Azure\Azure Dev Spaces CLI;C:\Program Files\Microsoft SDKs\Azure\Azure Dev Spaces CLI\;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\ProgramData\kind;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\Chocolatey\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Docker;C:\Program Files\PowerShell\7\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\lib\pulumi\tools\Pulumi\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\OpenSSL\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;c:\tools\php;C:\Program Files (x86)\sbt\bin;C:\Program Files\TortoiseSVN\bin;C:\SeleniumWebDrivers\ChromeDriver\;C:\SeleniumWebDrivers\EdgeDriver\;C:\Program Files\CMake\bin;C:\Program Files\Amazon\AWSCLIV2\;C:\Program Files\Amazon\SessionManagerPlugin\bin\;C:\Program Files\Amazon\AWSSAMCLI\bin\;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files (x86)\Microsoft BizTalk Server\;C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\x64\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\VC\Linux\bin\ConnectionManagerExe;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\x64\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\VC\Linux\bin\ConnectionManagerExe
...
======
======
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.9.4
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
The input line is too long.
The syntax of the command is incorrect.

As you can see, each execution of vcvarsall.bat adds (6971 - 4822 = 2149) characters to the head of the PATH environment variable. Therefore, during the third execution, after multiple executions of commands like set "PATH=bar;%PATH%" , the length of the command line which contains the content expanded from %PATH% (see below) will eventually exceed 8192.

What is %PATH% :

Syntax

Remarks

  • If you call a variable value from a batch file, enclose the value with percent signs (%). For example, if your batch program creates an environment variable named BAUD, you can use the string associated with BAUD as a replaceable parameter by typing %baud% at the command prompt.

from: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1#syntax

Suggestion

You should not run this action multiple times. If you want to build an application with multiple development environments on GitHub Actions, you should use the strategy.matrix feature because it can isolate the environments and execute steps in parallel in each isolated environment.

@ilammy
Copy link
Owner

ilammy commented May 8, 2021

Wow, @pzhlkj6612, thanks for a detailed analysis! (And the one in the other issue as well).

Somehow it did not occur to me that @kwhat's issue might be caused by environment variable overflow. I can still reproduce the issue, but I'm unsure what to do about it.

I guess your advice to avoid running this action multiple time is the best. You don't normally launch a developer command prompt out of another developer command prompt, the same is true here.

I have played around with deduplicating path-like environment variables, attempting to correct the behavior of vcvarsall.bat that just blindly prepends-appends its stuff. That works for those variables – as in, avoiding the failure to run this action multiple times with different architectures. But there are more subtle issues which are not as easy to correct. For example, there are some variables that vcvarsall.bat sets but never unsets on repeated invocations. One that I've noticed are __DOTNET_ADD_{32,64}BIT. GitHub Actions don't have an ability to remove a variable for further steps, and we can't really detect that a variable should not be there in the first place – because vcvarsall.bat does not remove it.

I believe it would work to launch this action multiple times in a row, in some limited use cases, but I would certainly not recommend it. I guess I will settle on applying the deduplication hack, coupled with maybe issuing a warning on repeated invocations (with an option to suppress it if you're sure it works for you). I'll think on an approach for that.

@ilammy
Copy link
Owner

ilammy commented May 8, 2021

(GitHub should provide a way to opt out of automatically closing issues mentioned in a PR. The fact that something has been merged does not mean that it was released. And the fact that it was released, does not mean that the issue has been resolved.)

@ilammy ilammy reopened this May 8, 2021
@pzhlkj6612
Copy link
Contributor

GitHub should provide a way to opt out of automatically closing issues mentioned in a PR

Well, you used the "Resolves" keyword to link this issue with that PR, so it happened.

@ilammy
Copy link
Owner

ilammy commented May 8, 2021

@kwhat, I've just released v1.8.0 which should allow reconfiguration. Could you please try it out?

ilammy/msvc-dev-cmd@v1 should already point to that release.

@ilammy
Copy link
Owner

ilammy commented May 8, 2021

@pzhlkj6612,

GitHub should provide a way to opt out of automatically closing issues mentioned in a PR

Well, you used the "Resolves" keyword to link this issue with that PR, so it happened.

Yeah, that thing exists. But it would be nice to be able to still use those words as markers without actually closing issues. There is a list of linked PRs and issues, but it's not possible to “uncheck” things there to prevent automatic closure.

</rant>

@pzhlkj6612
Copy link
Contributor

There is a list of linked PRs and issues, but it's not possible to “uncheck” things there to prevent automatic closure.

Indeed. We can only use "plain" references like #<issue_id> in the comment. It's not a prefect bug tracker so far.

@pzhlkj6612
Copy link
Contributor

GitHub Actions don't have an ability to remove a variable for further steps

What if we set the value of those variables to empty?

@ilammy
Copy link
Owner

ilammy commented May 9, 2021

What if we set the value of those variables to empty?

Then they will be empty. A variable with "empty string" as a value. This is different from "not present in the environment". How this is handled is up to the software that queries them. It might consider them missing, or it might fail with an "invalid value" error.

While I haven't noticed any variables so far that could cause problems, the possibility still remains. I thought that it's better to allow reconfiguration in some way over not allowing it at all. If it works in most cases and no one runs into issues – great. If this does not work for someone – I hope they'll raise an issue and that specific issues can be addressed, rather then me trying to prevent a hypothetical situations proactively by applying random hacks. (I mean, if there was an obvious documented way to remove variables and if vsvarsall.bat did remove some variables after reconfiguration then I'd do that of course. But there isn't and it doesn't.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants