Follow these steps to have bundle ignore private gems on Heroku:
- Enable user-env-compile:
heroku labs:enable user-env-compile -a myapp
- Add a config to heroku to indicate it is heroku:
heroku config:set HEROKU=true -a myapp
- Use logic in the Gemfile
Disclaimer: The downside is that Gemfile.lock will have more gem then bundler can see. It will therefore think the lock file is invalid, ignore it, and regenerate it. This is fine if you your gems mostly uptodate and include version in the Gemfile for the important gems like rails.