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

Cannot find git executable on on windows-2022 (GitHub-hosted runner) #136

Closed
ochococo opened this issue Oct 18, 2022 · 4 comments
Closed

Comments

@ochococo
Copy link
Contributor

Observed error on windows-2022 (GitHub-hosted runner) that git command cannot be found:

Config:

- uses: actions/checkout@v2
- uses: webfactory/ssh-agent@v0.5.4
    with:
    ssh-private-key: |
        ${{ secrets.[redacted] }}
        ${{ secrets.[redacted] }}

Result:

'git' is not recognized as an internal or external command,
[198](https://github.com/[redacted]#step:4:199)
operable program or batch file.
[199](https://github.com/[redacted]#step:4:200)
Error: Command failed: git config --global --replace-all url."git@key-[redacted].[redacted]".insteadOf "https://github.com/[redacted]"
[200](https://github.com/[redacted]#step:4:201)
'git' is not recognized as an internal or external command,
[201](https://github.com/[redacted]#step:4:202)
operable program or batch file.
mpdude pushed a commit that referenced this issue Oct 19, 2022
…tHub-hosted runner) (#137)

### Problem:
Observed error on `windows-2022` ([GitHub-hosted runner](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources)) that `git` command cannot be found.

### Issue: 

Cannot find git executable on on windows-2022 (GitHub-hosted runner) #136 

### Solution:
This path improvement makes use of existing `path.js` to resolve and return correct `git.exe` path for Windows, leaving the executable name as it was for other operating systems.

### Caveats:
No idea how and why this `c://progra~1//git//usr//bin//git.exe` mumbo-jumbo works but it apparently did for other executables so figured it should work for `git.exe` (and it does).
@ochococo
Copy link
Contributor Author

ochococo commented Oct 19, 2022

NOTE: Close after #137 and #140 changes are released.

mpdude added a commit that referenced this issue Oct 19, 2022
This PR fixes an apparently wrong path to the `git` binary that was added in #136. 

According to actions/checkout#928 (comment), the path should not contain the `usr/` part, although for `ssh-add` and `ssh-agent`, it has to.
@ochococo
Copy link
Contributor Author

@mpdude We could consider using something like that:

const io = require('@actions/io');
gitCmd = await io.which('git.exe')

My js skills are too rusty to attempt it 🛑

@ochococo
Copy link
Contributor Author

Tested webfactory/ssh-agent@8a9e20a5860cb7f6b3a1d92a74799581e054d850 and can confirm it works:

image

@mpdude
Copy link
Member

mpdude commented Oct 19, 2022

Released v0.7.0.

@mpdude mpdude closed this as completed Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants