Skip to content

git update-git-for-windows --yes does not work in GitHub workflows #5230

Open
@dscho

Description

@dscho

It was reported by @rotu in #5199 (comment) that it does not work:

- name: Update git for windows
    if: runner.os == 'Windows'
    run: git update-git-for-windows --yes
    shell: cmd
2024-10-24T17:31:41.3652735Z �[36;1mgit update-git-for-windows --yes�[0m
2024-10-24T17:31:41.3677331Z shell: C:\Windows\system32\cmd.EXE /D /E:ON /V:OFF /S /C "CALL "{0}""
2024-10-24T17:31:41.3678050Z ##[endgroup]
2024-10-24T17:31:43.6864522Z Git for Windows 2.47.0.windows.1 (64-bit)
2024-10-24T17:31:44.0033217Z Update 2.47.0.windows.2 is available
2024-10-24T17:31:44.5000031Z Downloading Git-2.47.0.2-64-bit.exe
...
2024-10-24T17:31:44.9470534Z ######################################################################## 100.0%
2024-10-24T17:31:51.5451678Z ##[error]Process completed with exit code 2.

It could be a modal dialog? If so, it should be possible to capture it with something like this PowerScript:

[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
function screenshot([Drawing.Rectangle]$bounds, $path) {
   $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
   $graphics = [Drawing.Graphics]::FromImage($bmp)
   $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
   $bmp.Save($path)
   $graphics.Dispose()
   $bmp.Dispose()
}
$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1000, 900)
screenshot $bounds "C:\screenshot.png"

Another idea would be to run the git-update-git-for-windows script with tracing turned on:

- run: |
    sh -x /mingw64/bin/git-update-git-for-windows

or to dig into it by debugging with tmate:

- uses: mxschmitt/action-tmate@v3
  with:
    detached: true

However, my money is on this part of the script which tries to ensure that the (interactive) Bash session is quit forcefully lest an updated MSYS2 runtime prevent an orderly exit.

Now, if that last hunch is correct, I could imagine that we need to add a special case for when $GITHUB_ACTIONS is non-empty and simply skip that code block in that scenario.

@rotu, would you like to give this a try?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions