Configure Bundler for Access to Private Repositories

CategoriesRuby on Rails

What worked for me is using ENV VARs:


gem 'iron_warbler', :git => "https://piousbox:#{ENV['GITHUB_TOKEN']}@github.com/wasyaco/iron_warbler.git", :branch => '0.1.0'

What didn’t but should have worked is reproduced below:

You can add authentication information to it like this:

$ bundle config GITHUB__COM username:password
$ bundle config --local GITHUB__COM username:password

Bundler actually allows all config options to also be set via environment variables:

$ export BUNDLE_GITHUB__COM=username:password

Or if you’re using personal access tokens

$ export BUNDLE_GITHUB__COM=x-access-token:<token>

This technique works really well with Travis and Heroku, since they allow environment variables to be stored securely.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.