checkout icon indicating copy to clipboard operation
checkout copied to clipboard

Post Checkout use of different git executable leads warnings

Open speters opened this issue 3 years ago • 0 comments

Problem

A Cygwin installation in a workflow adds its "bin" directory to the PATH during installation. This makes C:\cygwin\bin\git.exe taking precedence in the path search over original C:\Program Files\Git\bin\git.exe which causes some warnings during the Post Checkout:

The process 'C:\cygwin\bin\git.exe' failed with exit code 128

Expected behaviour

It was expected that Post Checkout step uses the same tools as were used during Checkout.

Maybe save the full path to the git.exe used during Checkout to use it again in Post Checkout. Or find a solution which works with either Cygwin or provided git.exe, which would also fix https://github.com/actions/checkout/issues/767

Preliminary Solution

As I am unable to strip the Cygwin path from PATH, I worked around this issue by adding a "cleanup" step as last step:

    - name: Cleanup
      shell: powershell
      # this prevents the intrinsic "Post Checkout" step from accessing git.exe from Cygwin
      run: Rename-Item C:\cygwin\bin\git.exe cygwin_git.exe

Logs

Log with warning

This one calls C:\cygwin\bin\git.exe because PATH environment variable was changed:

2022-08-30T12:18:49.5439101Z Post job cleanup.
2022-08-30T12:18:52.6834217Z [command]C:\cygwin\bin\git.exe version
2022-08-30T12:18:52.7116092Z git version 2.37.2
2022-08-30T12:18:52.7167670Z Copying 'C:\Users\runneradmin\.gitconfig' to 'D:\a\_temp\d1f8269a-a628-4df7-8451-2c195b30fb0b\.gitconfig'
2022-08-30T12:18:52.7193755Z Temporarily overriding HOME='D:\a\_temp\d1f8269a-a628-4df7-8451-2c195b30fb0b' before making global git config changes
2022-08-30T12:18:52.7194445Z Adding repository directory to the temporary git global config as a safe directory
2022-08-30T12:18:52.7207583Z [command]C:\cygwin\bin\git.exe config --global --add safe.directory D:\a\vcontrold-tmp\vcontrold-tmp
2022-08-30T12:18:52.7517177Z [command]C:\cygwin\bin\git.exe config --local --name-only --get-regexp core\.sshCommand
2022-08-30T12:18:52.7805963Z fatal: --local can only be used inside a git repository
2022-08-30T12:18:52.7831090Z [command]C:\cygwin\bin\git.exe submodule foreach --recursive "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2022-08-30T12:18:53.4804285Z fatal: detected dubious ownership in repository at '/cygdrive/d/a/vcontrold-tmp/vcontrold-tmp'
2022-08-30T12:18:53.4805758Z To add an exception for this directory, call:
2022-08-30T12:18:53.4809517Z 
2022-08-30T12:18:53.4810610Z 	git config --global --add safe.directory /cygdrive/d/a/vcontrold-tmp/vcontrold-tmp
2022-08-30T12:18:53.5009972Z ##[warning]The process 'C:\cygwin\bin\git.exe' failed with exit code 128
2022-08-30T12:18:53.5252515Z Cleaning up orphan processes
Log without warning
2022-08-30T15:30:30.8559531Z Post job cleanup.
2022-08-30T15:30:34.0075246Z [command]"C:\Program Files\Git\bin\git.exe" version
2022-08-30T15:30:34.0385538Z git version 2.37.2.windows.2
2022-08-30T15:30:34.0461134Z Copying 'C:\Users\runneradmin\.gitconfig' to 'D:\a\_temp\87b18e68-68e0-47a7-9504-33ac83566a8e\.gitconfig'
2022-08-30T15:30:34.0488554Z Temporarily overriding HOME='D:\a\_temp\87b18e68-68e0-47a7-9504-33ac83566a8e' before making global git config changes
2022-08-30T15:30:34.0489277Z Adding repository directory to the temporary git global config as a safe directory
2022-08-30T15:30:34.0500135Z [command]"C:\Program Files\Git\bin\git.exe" config --global --add safe.directory D:\a\vcontrold-tmp\vcontrold-tmp
2022-08-30T15:30:34.0794610Z [command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp core\.sshCommand
2022-08-30T15:30:34.1088326Z [command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2022-08-30T15:30:34.6522529Z [command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2022-08-30T15:30:34.6763120Z http.https://github.com/.extraheader
2022-08-30T15:30:34.6803561Z [command]"C:\Program Files\Git\bin\git.exe" config --local --unset-all http.https://github.com/.extraheader
2022-08-30T15:30:34.7087455Z [command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2022-08-30T15:30:35.3055172Z Cleaning up orphan processes

speters avatar Aug 30 '22 15:08 speters