If your Gemfile has a privately hosted package referenced similar to this:
gem 'sekret', git: 'https://github.com/my-private-group/sekret.git', branch: 'main'
You may see a prompt when running bundle install
, or other bundler commands, to enter your github username & password.
To resolve this, you need to generate a token and add it to your system.
- Log in with your Github account and visit the tokens page
- Add a meaningful name, set your expiration, and grant
repo
access - Copy the token for use later
To successfully run bundle install
locally, you need to either add:
- A token to your local repo with
bundle config --local github.com <token>
- Confirm with
cat .bundle/config
and see your token
- A token to your global bundle config with
bundle config --global github.com <token>
- Confirm with
cat ~/.bundle/config
and see your token
- To your environment with an environment variable
export BUNDLE_GITHUB__COM=<token>
- Confirm with
env | grep BUNDLE_GITHUB__COM
and see your token
- For CI/CD you probably don't want to use a personal token. Use a "bot" account (Github suggests this) with limited access
- Each engineer should/could use their own token locally
- You can also use dotenv or anything else
- There are reasons to use each of the above ways of setting a token