I use a gem, my_gem
stored on github in an app, my_app
. The Gemfile
looks like this:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.4'
gem 'rails', '~> 5.2.6'
...
gem 'my_gem', git: "https://#{ENV['PRIVATE_LIB_TOKEN']}:x-oauth-basic@github.com/obromios/my_gem.git", branch: 'master'
About a year ago, I was able to bundle install
the app and push to heroku
but this no longer works. I reissued an new private access token from Github, giving it access to the repo, and set it in my .env file as follows
PRIVATE_LIB_TOKEN=<token>
When I type bundle install
I get the following error message
remote: Repository not found.
fatal: Authentication failed for 'https://github.com/obromios/my_gem.git/'
Retrying `git clone https://x-oauth-basic@github.com/obromios/my_gem.git /Users/my_name/.rvm/gems/ruby-2.7.4/cache/bundler/git/my_gem-<some_other_token> --bare --no-hardlinks --quiet` at /Users/my_name/xyz/my_app due to error (2/4): Bundler::Source::Git::GitCommandError Git error: command `git clone https://x-oauth-basic@github.com/obromios/my_gem.git /Users/my_name/.rvm/gems/ruby-2.7.4/cache/bundler/git/my_gem-<some_other_token> --bare --no-hardlinks --quiet` in directory my_app has failed.
If this error persists you could try removing the cache directory '/Users/my_name/xyz/my_app'
Looking at /Users/my_name/.rvm/gems/ruby-2.7.4/cache/bundler/git/
there was a directory named my_gem-<yet_another_token>. The tokens are all different but are random hashes of similar length. I removed the my_gem-<yet_another_token>
directory and this did not help. I also deleted /Users/xyz/my_app
and reinstalled the app, but this did not work.
I note that since last time that this worked, I had set up two factor authentication on Github.
How do I fix this?