question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to import packages from private repo

See original GitHub issue

Bug description

Have two packages hosted on github as private repos.

Getting this error:

An error occurred while resolving packages:
  Project has invalid dependencies:
    <package_id>: Error when executing git command. Failed to add the ECDSA host key for IP address '140.82.114.4' to the list of known hosts (/root/.ssh/known_hosts).
    ERROR: Repository not found.
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

(140.82.114.4 is a github.com ip)

How to reproduce

Yaml snippet:

      # setup ssh agent to access private package repos in manifest
      - uses: webfactory/ssh-agent@v0.5.4
        with:
          ssh-private-key: |
            ${{ secrets.SSH_PRIVATE_KEY }}
            ${{ secrets.SSH_PRIVATE_KEY_TWO }}
            
      # test git clone (this successfully clones the repos, suggesting ssh-agent is setup properly)
      # - name: Git Clone Test
      #   run: |
      #     git clone git@github.com:<repo_1>.git
      #     git clone git@github.com:<repo_2>.git
      #     cd <repo_folder>
      #     ls

      # Build
      - name: Build project
        uses: game-ci/unity-builder@v2
        env:
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
          UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
        with:
          targetPlatform: iOS
          sshAgent: ${{ env.SSH_AUTH_SOCK }}

Format in manifest is: ssh://git@github.com/<company>/<project>.git

Expected behavior

I expect it to successfully import these packages

Additional details

Followed these docs: https://game.ci/docs/github/builder#private-github-repositories And ssh-agent docs: https://github.com/webfactory/ssh-agent

As per ssh-agent recommendations found, I also tried manually cloning the repos (see yaml) – this worked fine, so I don’t think there’s an issue with my ssh-agent setup. Seems to break only when importing packages. If it matters, I did notice this log when I manually cloned: Warning: Permanently added the ECDSA host key for IP address '140.82.114.3' to the list of known hosts. (140.82.114.3 is another github ip). Maybe the problem has to do with it failing to do so in unity-builder container?

Also tried webfactory/ssh-agent@v0.5.2 (what’s currently in Game-CI docs).

Have tried other formats in the manifest (one above seems closest to what Unity prescribes) with no luck. Tried the url format in terminal and it seems to work:

Hi <company>/<project>! You've successfully authenticated, but GitHub does not provide shell access.

So as far as I can tell, I have everything configured correctly on my end. Any ideas?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
justin-piercecommented, Mar 22, 2022

Hello, I am also struggling with the same bug, @justin-pierce could you please show me how exactly you did your workaround? Maybe it will help me out too

This clones the package repos locally (you still need to setup ssh-agent correctly for multiple private repos, see my snippets above) and runs a shell script to set the package manifest to point to the local files (and prints the manifest file so you can confirm the changes worked as you intended)

      - name: Clone Packages To Use Locally
        run: |
          git clone git@github.com:<git_url_1>.git
          git clone git@github.com:<git_url_2>.git
          echo "Editing package manifest"
          chmod +x edit_packages.sh
          source edit_packages.sh
          cat Packages/manifest.json

edit_packages.sh looks like this:

#!/usr/bin/env bash

sudo sed -i "s|<git_url_1>|file:../<package_1>|" Packages/manifest.json
sudo sed -i "s|<git_url_2>|file:../<package_2>|" Packages/manifest.json

the sed command is simple string replacement – s|<string to replace>|<string to replace it with>|

Because you’re editing stuff after checkout, you’ll need to set allowDirtyBuild: true in the unity-builder step’s with section

you may have to mess with paths depending on your setup – just make sure the packages are cloned outside the Assets folder and that the package manifest points to the path you cloned them to.

and for clarity, this workaround doesn’t require a custom fork of unity-builder

2reactions
justin-piercecommented, Mar 15, 2022

I have a workaround but it’s not ideal – I just clone the repos outside of the docker container and reference the files locally in the package manifest. Requires me to enable dirty builds, which I’d like to avoid but it’s fine for now.

I think this is related to unity-builder not correctly implementing support for multiple keys inside the docker container: https://github.com/webfactory/ssh-agent/issues/78

I tried forking my own unity-builder to apply the suggested fix, got close but couldn’t get it working quickly enough so I gave up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to import Private Repo using setup.py
I am trying to import the private repo but I am getting an error. from setuptools import setup, find_packages ...
Read more >
Problems on Import from private repository using username ...
When importing a private repository configured to be mirrored, you need to give a username and password for authentication.
Read more >
Unable to import github repo in bitbucket using ...
Show activity on this post. I am importing a repo that is in GitHub to bitbucket using the import statement. Looks like an...
Read more >
How to Import a Private Git Repo from Github
A guide for the error "Can't connect to URL" when importing a private repo from Github.
Read more >
Importing private repos from Github | by Romenigue Thier
When you work with a private repository you must use some kind of authentication. Usually is used a ssh key to communicate with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found