Bundle install can't access to the custom Gem in Github private repository

Hi,

I have an issue. I have a project working with CircleCI for a long time. In last terms, we decided to extract some logic to separate Gem - also located on Github.

Here I faced my issue.

When I do: run: bundle install in one of my step I’m getting information that CircleCi can’t access my Gem repository.

What I’ve already done. Since Github doesn’t allow us to set the same SSH for two repositories I had to generate a new one for mu custom_gem.

I setup Deploy Keys on Github with proper access.
I went to CircleCi’s project’s configuration page. Added my new key in an SSH Permissions section (I considered adding this in a Checkout SSH keys but couldn’t find an option to add the second key there…).

My steps, unfortunately, didn’t help so far. I still get the same error:

> #!/bin/bash -eo pipefail
bundle install
Fetching gem metadata from https://rubygems.org/......
Fetching https://github.com/plashchynski/crono.git
Warning: Permanently added the RSA host key for IP address 'some IP' to the list of known hosts.

Fetching https://github.com/taskrabbit/makara.git
Fetching https://github.com/repozitory_namespace/my_custome_gem_name.git
ERROR: Permission to repozitory_namespace/my_custome_gem_name.git denied to deploy key
fatal: Could not read from remote repository.

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

Retrying `git clone 'https://github.com/repozitory_namespace/my_custome_gem_name.git' "/home/circleci/repo/vendor/bundle/cache/bundler/git/my_custome_gem_name-4ae49c7f2ab9b1350c51c94ed2625b620948f192" --bare --no-hardlinks --quiet` due to error (2/4): Bundler::Source::Git::GitCommandError Git error: command `git clone 'https://github.com/repozitory_namespace/my_custome_gem_name.git' "/home/circleci/repo/vendor/bundle/cache/bundler/git/my_custome_gem_name-4ae49c7f2ab9b1350c51c94ed2625b620948f192" --bare --no-hardlinks --quiet` in directory /home/circleci/repo has failed.ERROR: Permission to repozitory_namespace/my_custome_gem_name.git denied to deploy key
fatal: Could not read from remote repository.

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

Retrying `git clone 'https://github.com/repozitory_namespace/my_custome_gem_name.git' "/home/circleci/repo/vendor/bundle/cache/bundler/git/my_custome_gem_name-4ae49c7f2ab9b1350c51c94ed2625b620948f192" --bare --no-hardlinks --quiet` due to error (3/4): Bundler::Source::Git::GitCommandError Git error: command `git clone 'https://github.com/repozitory_namespace/my_custome_gem_name.git' "/home/circleci/repo/vendor/bundle/cache/bundler/git/my_custome_gem_name-4ae49c7f2ab9b1350c51c94ed2625b620948f192" --bare --no-hardlinks --quiet` in directory /home/circleci/repo has failed.ERROR: Permission to repozitory_namespace/my_custome_gem_name.git denied to deploy key
fatal: Could not read from remote repository.

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

Retrying `git clone 'https://github.com/repozitory_namespace/my_custome_gem_name.git' "/home/circleci/repo/vendor/bundle/cache/bundler/git/my_custome_gem_name-4ae49c7f2ab9b1350c51c94ed2625b620948f192" --bare --no-hardlinks --quiet` due to error (4/4): Bundler::Source::Git::GitCommandError Git error: command `git clone 'https://github.com/repozitory_namespace/my_custome_gem_name.git' "/home/circleci/repo/vendor/bundle/cache/bundler/git/my_custome_gem_name-4ae49c7f2ab9b1350c51c94ed2625b620948f192" --bare --no-hardlinks --quiet` in directory /home/circleci/repo has failed.ERROR: Permission to repozitory_namespace/my_custome_gem_name.git denied to deploy key
fatal: Could not read from remote repository.

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

Git error: command `git clone 'https://github.com/repozitory_namespace/my_custome_gem_name.git'
"/home/circleci/repo/vendor/bundle/cache/bundler/git/my_custome_gem_name-4ae49c7f2ab9b1350c51c94ed2625b620948f192"
--bare --no-hardlinks --quiet` in directory /home/circleci/repo has failed.
Exited with code 11

Do you have any ideas about what else can I do here? Or how can I add SSH key to: Checkout SSH keys and if it is going to solve my issue?

Just to make sure, would you try recreating your deploy keys, then pushing a new commit? You can find more details on how to do that in this Support Center article.

Let us know if you try that, and still have trouble!

We are having the exact same issue.

  • Either you need to add these magical keys for each project individually, generating news ones every time
  • Or this feature is not supported.

Cause the documentation steps are not working.
We have a machine user SSH key we want to use for our projects as well and not newly generated keys for every single project, because that’s simply too much effort to set up every single time (700 repo’s and 50 developers)