Search code examples
ruby-on-railsgithubrubygemsbundlercircleci

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


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

Solution

  • 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.)