2

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
user664833
  • 18,397
  • 19
  • 91
  • 140
  • I really just want an answer (from anyone) - I don't care about "reputable source" - I think next time I will chose "draw attention to this question". Sorry! – user664833 Dec 28 '20 at 17:59

6 Answers6

0

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

Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
  • Thank you for your trying to help me. Unfortunately `bundle update` had no effect (no files were changed). I suspected that result because I had already ran `bundle install` and committed changes to `Gemfile` and `Gemfile.lock` (because I updated the gem from `0.7.1` to `0.7.2` in an attempt to debug the situation. I am at a loss for more things to try. Thanks again. – user664833 Dec 25 '20 at 01:25
  • Locally it does nothing (no changes to lockfile). On CI, it shows error: `Unable to find a spec satisfying my_cool_gem (~> 2.0) in the set. Perhaps the lockfile is corrupted?` – kolen Mar 05 '21 at 20:20
0

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.

pixelearth
  • 13,674
  • 10
  • 62
  • 110
  • 1
    Thanks for trying to help me. Yes, I have verified that the gem is available at the source. It is listed in `https://github.com/orgs/my_cool_org/packages` (I formatted the URL as code because I don't want it turned into a link since I'm using the `my_cool_gem` stub). – user664833 Dec 28 '20 at 19:35
0

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

user664833
  • 18,397
  • 19
  • 91
  • 140
  • I get `Bad username or password for …` error in this case. – kolen Mar 05 '21 at 20:06
  • If password is not set (delete `~/.bundle/config`), the error would be `Authentication is required for rubygems.pkg.github.com`. So it's unlikely the cause. – kolen Mar 05 '21 at 20:16
  • Most probably that key was *valid*, but it had no permission for that repository. Github separates gems in registry per repository, despite there's single registry URL per organization. – kolen Mar 05 '21 at 21:48
0

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

TTD
  • 301
  • 1
  • 7
  • Thank you, but I happened to have already figured it out - as per my answer above... though the variable was set, it was invalid (I believe because the user who created the authentication token had been removed from the organisation). – user664833 Dec 30 '20 at 18:34
  • For me, `gem search` with `--all` searches rubygems.org only, so no that gem, both locally (where `bundle install` works) and on CI (where it doesn't). `sudo gem update --system` didn't help. – kolen Mar 05 '21 at 20:10
0

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".

kolen
  • 2,752
  • 2
  • 27
  • 35
0

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
user664833
  • 18,397
  • 19
  • 91
  • 140