3

I recently changed my Personal Access Token on GitHub, and I think I've put the new token in all the right places... but maybe I am missing a place?

The problem:

$ git push staging my_cool_branch:master
...
...
...
remote: -----> Installing dependencies using bundler 2.2.33
remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote:        Fetching gem metadata from https://rubygems.org/.......
remote:        Fetching gem metadata from https://rubygems.pkg.github.com/private_org/.
remote:        
remote:        
remote:        Bad username or password for https://bart_simpson@rubygems.pkg.github.com/private_org/.
remote:        Please double-check your credentials and correct them.
remote:        Bundler Output: Fetching gem metadata from https://rubygems.org/.......
remote:        Fetching gem metadata from https://rubygems.pkg.github.com/private_org/.
remote:        
remote:        
remote:        Bad username or password for https://bart_simpson@rubygems.pkg.github.com/private_org/.
remote:        Please double-check your credentials and correct them.
remote: 
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
...
...
...

Files (that I am aware of) with Personal Access Token:

$ cat ~/.bundle/config 
---
BUNDLE_RUBYGEMS__PKG__GITHUB__COM: "bart_simpson:ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f"
BUNDLE_HTTPS://RUBYGEMS__PKG__GITHUB__COM/PRIVATE_ORG/: "bart_simpson:ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f"

and

$ cat ~/.gem/credentials
---
:github: Bearer ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f

and

$ cat ~/.gemrc 
---
:backtrace: false
:bulk_threshold: 1000
:sources:
- https://rubygems.org/
- https://bart_simpson:ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f@rubygems.pkg.github.com/private_org/
:update_sources: true
:verbose: true
notapatch
  • 6,569
  • 6
  • 41
  • 45
user664833
  • 18,397
  • 19
  • 91
  • 140

1 Answers1

3

Ah, see ~/.bundle/config above?

The solution was that I also had to set BUNDLE_RUBYGEMS__PKG__GITHUB__COM to the new token in staging:

heroku config:set BUNDLE_RUBYGEMS__PKG__GITHUB__COM=bart_simpson:ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f

...which, btw, means that you must also set it in .env:

BUNDLE_RUBYGEMS__PKG__GITHUB__COM=bart_simpson:ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f
BUNDLE_GITHUB__COM=x-access-token:ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f
user664833
  • 18,397
  • 19
  • 91
  • 140
  • There is a bundler command to add the setting: `bundle config set --global rubygems.pkg.github.com your:creds` – MegaTux Apr 28 '23 at 14:14