Outstanding Questions
A list of outstanding questions to be answered before finalizing this document.
- How does on update vendored gems? Are the automatically updated when you run
bundle update
or do you have to runbundle package
again?- How do you tell Heroku's build process to use
bundle install --local --no-prune
when building the build pack?
The purpose of this is to outline the cleanest way to vendor ruby gems from a private github repo, or private gem servers, so as not to have to commit and sensitive keys, tokens, urls, etc. while still being able to install on Heroku.
The Gemfile
First, move any and all gems that are being installed from a private gem server to instead use github.
gem 'rails'
gem 'my-private-gem', github: 'my-company/my-private-gem', tag: '0.0.1'
The Vendoring
This will store all gem
files in vendor/cache
as well as a copy of all github
repos referred to in your Gemfile
.
bundle package --no-install --all
The Install
This will install gem
files stored in vendor/cache
and reference the cache
directory for github based gems as well in your .bundle/config
.
bundle install --local --no-prune
The Gotcha
Because Rubygems doesn't support github based gems natively, bundler is providing the support for that. As such, you will need to ensure that bundler is setup in your app. (Rails should do this by default, BTW.)
# ensure bundler is setup
require 'bundler'
Bundle.setup