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

Windows workflow fails with "Could not read from remote repository" #202

Open
Robert-DEMCON opened this issue Jan 25, 2024 · 5 comments
Open

Comments

@Robert-DEMCON
Copy link

My Github action succeeds on Linux but fails on Windows the error:

Error: fatal: Could not read from remote repository.
Full log:

Run actions/checkout@v3
Syncing repository: workspace/this-repo
Getting Git version info
Copying 'C:\Users\runneradmin.gitconfig' to 'D:\a_temp\f6554cfe-9833-4920-999d-5ed3c171452b.gitconfig'
Temporarily overriding HOME='D:\a_temp\f6554cfe-9833-4920-999d-5ed3c171452b' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
"C:\Program Files\Git\bin\git.exe" config --global --add safe.directory D:\a\this-repo\this-repo
Deleting the contents of 'D:\a\this-repo\this-repo'
Initializing the repository
Disabling automatic garbage collection
"C:\Program Files\Git\bin\git.exe" config --local gc.auto 0
Setting up auth
Fetching the repository
Determining the checkout info
Checking out the ref
Setting up auth for fetching submodules
Fetching submodules
"C:\Program Files\Git\bin\git.exe" submodule sync
"C:\Program Files\Git\bin\git.exe" -c protocol.version=2 submodule update --init --force --depth=1
Submodule 'tests/private-repo' (https://github.com/workspace/private-repo.git) registered for path 'tests/private-repo'
Cloning into 'D:/a/this-repo/this-repo/tests/private-repo'...
ssh: Could not resolve hostname key-97c23a776206be62d055b3c8c9b8a91b0da7e1aa77e4bb609aaec6076a5583e2.github.com: Name or service not known
Error: fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: fatal: clone of 'https://github.com/workspace/private-repo.git' into submodule path 'D:/a/this-repo/this-repo/tests/private-repo' failed
Failed to clone 'tests/private-repo'. Retry scheduled
Cloning into 'D:/a/this-repo/this-repo/tests/private-repo'...
ssh: Could not resolve hostname key-97c23a776206be62d055b3c8c9b8a91b0da7e1aa77e4bb609aaec6076a5583e2.github.com: Name or service not known
Error: fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: fatal: clone of 'https://github.com/workspace/private-repo.git' into submodule path 'D:/a/this-repo/this-repo/tests/private-repo' failed
Failed to clone 'tests/private-repo' a second time, aborting
Error: The process 'C:\Program Files\Git\bin\git.exe' failed with exit code 1

My workflow file (with some bits redacted):

jobs:
  build:

    name: Pytest ${{ matrix.python-version }}, ${{matrix.os}}

    runs-on: ${{matrix.os}}

    strategy:
      fail-fast: true
      matrix:
        os: ["ubuntu-latest"]
        python-version: ["3.9", "3.10", "3.11"]
        include:
          - os: "windows-latest"
            python-version: "3.10"

    steps:
    - name: Place SSH private key to grant access to other repos
      uses: webfactory/[email protected]
      with:
          ssh-private-key: ${{ secrets.PRIVATE_KEY_FOR_PRIVATE_REPO }}
    - name: Recursively check out source code
      uses: actions/checkout@v3
      with:
        submodules: true

I also want to note I really like this tool! I am not entirely sure how well Windows is supported and if this should work at all.

Thanks.

@sykhro
Copy link

sykhro commented Feb 20, 2024

It's because of recursive submodules, see #130 (comment)

The workaround is to use the checkout action, init submodules manually, use this action, clone submodules manually.

@ultimaweapon
Copy link

I also having the same issue on Windows without submodules: true on actions/checkout after upgraded from v0.7.0 to v0.9.0. It is working fine on Linux. My Windows workflow:

name: Development Build
on:
  push:
    branches:
    - dev
  pull_request:
    branches:
    - dev
env:
  CARGO_NET_GIT_FETCH_WITH_CLI: true
concurrency: ${{ github.ref }}
permissions:
  contents: read
  id-token: write
jobs:
  windows:
    name: Build (Windows)
    runs-on: windows-latest
    steps:
    - name: Checkout source
      uses: actions/checkout@v4
    - name: Set up SSH agent
      uses: webfactory/[email protected]
      with:
        ssh-private-key: ${{ secrets.REDACED }}

The error:

     Updating git repository `ssh://[email protected]/REDACED/REDACED.git`
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
error: failed to get `REDACED` as a dependency of package `REDACED v0.1.0 (D:\a\REDACED\REDACED\REDACED\REDACED)`
Caused by:
  failed to load source for dependency `REDACED`
Caused by:
  Unable to update ssh://[email protected]/REDACED/REDACED.git#aa65b327
Caused by:
  failed to clone into: C:\Users\runneradmin\.cargo\git\db\REDACED-aaa97381c1f720a7
Caused by:
  process didn't exit successfully: `git fetch --tags --force --update-head-ok ssh://[email protected]/REDACED/REDACED.git +refs/heads/*:refs/remotes/origin/* +HEAD:refs/remotes/origin/HEAD` (exit code: 128)
Error: Process completed with exit code 1.

@Robert-DEMCON
Copy link
Author

Robert-DEMCON commented Feb 26, 2024

@sykhro thanks for your suggestion. It's still not working for me on Windows though. I now have the following workflow (again some bits are redacted):

jobs:
  build:

    name: Pytest ${{ matrix.python-version }}, ${{matrix.os}}

    runs-on: ${{matrix.os}}

    strategy:
      fail-fast: true
      matrix:
        os: ["ubuntu-latest"]
        python-version: ["3.9", "3.10", "3.11"]
        include:
          - os: "windows-latest"
            python-version: "3.11"

    steps:
    - name: Check out source code
      uses: actions/checkout@v4
    - name: Place SSH private key to grant access to other repos
      uses: webfactory/[email protected]
      with:
          ssh-private-key: ${{ secrets.PRIVATE_KEY_FOR_PRIVATE_REPO }}
    - name: Get submodules
      run: |
        git submodule init
        git submodule update

(Same results with checkout@v3 and [email protected].)

Full log of the submodule step:

##[debug]Evaluating condition for step: 'Get submodules'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Get submodules
##[debug]Loading inputs
##[debug]Loading env
Run git submodule init
##[debug]C:\Program Files\PowerShell\7\pwsh.EXE -command ". 'D:\a_temp\a8480a0d-975f-459f-9832-b07bd72e2dee.ps1'"
Submodule 'tests/private-repo' (https://github.com/org/private-repo.git) registered for path 'tests/private-repo'
Cloning into 'D:/a/repo/repo/tests/private-repo'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'https://github.com/org/private-repo.git' into submodule path 'D:/a/repo/repo/tests/private-repo' failed
Failed to clone 'tests/private-repo'. Retry scheduled
Cloning into 'D:/a/repo/repo/tests/private-repo'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'https://github.com/org/private-repo.git' into submodule path 'D:/a/repo/repo/tests/private-repo' failed
Failed to clone 'tests/private-repo' a second time, aborting
Error: Process completed with exit code 1.
##[debug]Finishing: Get submodules

Looks like it's the same problem as @ultimaweapon

EDIT: replacing git submodule ... with cd <submodule> && git clone <url> . also fails on Windows with the same error as above.

@Galathius
Copy link

Galathius commented Feb 29, 2024

We have the same issue, changing ssh-agent version from 0.9.0 to 0.6.0 helps. Magically, if you change it back in the same PR to 0.9.0 – then it still works, but start failing on new PRs.

@EdSabino
Copy link

I was reading the code, and i think the problem is the "homeSsh" variable which have the the root concat with /.ssh, but on windows path use "" instead of "/" so the ssh-agent are not finding the keys

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

5 participants