CircleCI says Your bundle could not be found in any of the sources listed in your Gemfile

Viewed 689

CircleCI install dependencies error:

Your bundle is locked to my_cool_gem (0.7.2), but that version could not be
found in any of the sources listed in your Gemfile. If you haven't changed
sources, that means the author of my_cool_gem (0.7.2) has removed it. You'll
need to update your bundle to a version other than my_cool_gem (0.7.2) that
hasn't been removed in order to install.

Screenshot of CircleCI output:

CircleCI cannot find my gem in any of the sources listed in the Gemfile

CircleCI can't find a gem that I published to GitHub Packages, yet I have no such problem in local development.

I have qualifying versions of RubyGems and Bundler, as per GitHub's docs - https://docs.github.com/en/free-pro-team@latest/packages/guides/configuring-rubygems-for-use-with-github-packages - and I believe I have followed the instructions to publish and use said published gems... and, again, usage works locally but fails in CircleCI...

RubyGems version:

-bash> gem --version
3.0.9

Bundler version:

-bash> bundle --version
Bundler version 1.17.3

Gemfile:

source 'https://rubygems.org'                                                   
source 'https://rubygems.pkg.github.com/my_cool_org'

gem 'my_cool_gem', '0.7.2'

Note that I have also tried:

source 'https://rubygems.org'                                                   
source 'https://rubygems.pkg.github.com/my_cool_org'

source 'https://rubygems.pkg.github.com/my_cool_org' do
  gem 'my_cool_gem', '0.7.2'
end
6 Answers

Try running bundle update my_cool_gem if it modifies Gemfile.lock that should fix it.

Have you verified that it's actually still available at the source? I know you said it works locally, but that could be because of local cached versions of the gem. Bundle won't try to install something that's already there.

You might be able to verify this by uninstalling it locally and running bundle install again.

Ensure that you've correctly set the environment variable for authenticating with rubygems.pkg.github.com.

(Though the variable may be set, the value may be incorrect - as was the case for me.)

Interesting, sounds like a image bug. What happens if you try to list all available versions of your gem? gem search ^gem_name$ --all?

Have you tried to force update beforehand? sudo gem update --system

For me, the problem was that access tokens was different on local machine and on CI. And the key on CI was valid, but it had no permission for specific repository containing requested gem.

Despite Github provides single registry per organization, gems are associated with company's repositories. And packages within registry will be visible or invisible depending on permissions to these repositories that access tokens have. For example, user can have access to some repositories of organization and don't have to others — if using that user's personal access token, only gems associated with permitted repositories will be visible. Others will be hidden, so the error is "that version cannot be found".

I ran into this again, and this time I could not solve it with the solution I used last time, and no other solution worked either, so instead I chose to temporarily work around the issue by placing a copy of the gem in question directly into my app (a process known as "vendoring"; see this, this, and this):

gem unpack my_cool_gem # note, I actually had to specify the version with -v 0.12.1

mkdir vendor/gems/

mv my_cool_gem-0.12.1 vendor/gems/

In Gemfile, use the :path option rather than :source:

gem 'my_cool_gem', '0.12.1', path: 'vendor/gems'

Then generate Gemfile.lock:

bundle install
Related