Installing a Gem on Heroku from a Private GitHub Repo ==== Sometimes you want to use a gem on Heroku that is in a private repository on GitHub. Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens. This method does **not** add your OAuth token to `Gemfile.lock`. It uses bundle config to store your credentials, and allows you to configure Heroku to use environment variables when deploying. 1. [Generate an OAuth token from GitHub](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) --- * You only need to check the repo scope when configuring the token permissions 2. Update Gemfile to use your private repository --- ```ruby gem 'my_private_repo', git: 'https://github.com/username/my_private_repo.git' ``` 3. Configure bundler with your OAuth token --- ```ruby bundle config github.com ``` Now bundle and if everything works locally you are ready to deploy to Heroku! 4. Finally add BUNDLE_GITHUB__COM to your Heroku environment --- ```bash $ heroku config:add BUNDLE_GITHUB__COM= ``` You now have a private gem installed on Heroku! Optional - configure bundler to use your local repo in development --- bundle config has another option to work against your local git repository without updating your `Gemfile` The catch is that you need to specify the git branch when configuring the gem ```ruby gem 'my_private_repo', git: 'https://github.com/username/my_private_repo.git', branch: 'master' ``` Then run `bundle config local.ecto ` More information [here](http://bundler.io/v1.3/bundle_config.html) - see the section "Local git repositories" at the end