Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Troubleshooting Node.js Apps
      • Working with Node.js
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • Working with PHP
      • PHP Behavior in Heroku
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
    • Heroku Inference
      • Inference API
      • Quick Start Guides
      • Inference Essentials
      • AI Models
    • Vector Database
    • Model Context Protocol
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Language Support
  • Ruby
  • Working with Bundler
  • Bundler Configuration

Bundler Configuration

English — 日本語に切り替える

Last updated February 08, 2018

Table of Contents

  • Environment variable behavior
  • Gem source username and password
  • Gem build configuration settings

Bundler can be configured locally by using the command bundle config which can either set global options or local options in a .bundle/config file. We recommend that you do not check this .bundle/config file into your source control as it contains local paths that can vary from system to system. Instead, it is recommended that you use environment variables to configure Bundler on Heroku.

Environment variable behavior

Most settings that you want to pass as arguments to bundle install can be set via an environment variable. For example instead of bundle install --without development:test:ci, you can configure Bundler using a BUNDLE_ prefix environment variable. For the --without flag, this would be:

$ heroku config:set BUNDLE_WITHOUT=development:test:ci

Gem source username and password

For gem sources that are password protected, you can set a username and password using a specially crafted environment variable. For example, if you are trying to connect to a secure gem server on contribsys.com you previously would have added this to your Gemfile:

gem "mygem", source: "https://#{ ENV['CONTRIBSYS_USERNAME_PASSWORD'] }@gems.contribsys.com"

Now, instead you can declare your source without a username and password:

gem "mygem", source: "https://gems.contribsys.com"

Then, in your config, you can set the username and password:

$ heroku config:set BUNDLE_GEMS__CONTRIBSYS__COM=<username:password>

You will have to set the environment variable based on the domain name of the source you want. Periods are not valid in environment variables, so you can use a double underscore __ to indicate a period.

You can verify your environment variable formatting by running bundle config locally and using that environment variable:

$ env BUNDLE_GEMS__CONTRIBSYS__COM=<username:password> bundle config

gems.contribsys.com
Set via BUNDLE_GEMS__CONTRIBSYS__COM: "<username:password>"

You’ll need to replace username and password with your actual values. Don’t forget to put a colon between the two.

Another example would be using https://gem.fury.io. The Bundler environment variable equivalent would be BUNDLE_GEM__FURY__IO.

To verify that this is working, you can install the protected gems locally. First uninstall the gem locally. For example if you are using sidekiq in your gemfile:

gem "sidekiq-pro", source: "https://gems.contribsys.com/"

You’ll need to remove your allready installed gem from your local machine:

$ gem uninstall sidekiq-pro

Then verify the re-install works correctly:

$ BUNDLE_GEMS__CONTRIBSYS__COM=<username:password> bundle install

If that fails locally then it will also fail on Heroku.

If you are getting an error message while deploying to Heroku:

Authentication is required for https://gems.contribsys.com/.
Please supply credentials for this source.

Verify that the installation works locally using the above steps.

Gem build configuration settings

Some gems that have native extensions may need additional flags provided directly to the gem at install time.

For example the mysql gem needs to know where to find the configuration options. If you were to gem install this on a system, you would have to run a command with the --with-mysql-config flag like this:

$ gem install mysql -- --with-mysql-config=<path/to/mysql_config>

Bundler supports passing these flags through build settings. The key is build.<name-of-gem>. For mysql, it would be build.mysql. The environment variable version would be BUNDLE_BUILD__MYSQL. You could set this value on Heroku using:

$ heroku config:set BUNDLE_BUILD__MYSQL=<path/to/mysql_config>

Heroku does not have mysql installed, so in this example we don’t provide a working path. You would need a buildpack that installs mysql and then you could point this environment variable to the appropriate config location.

As with gem source, you can check your environment variable formatting using bundle config locally:

$ env BUNDLE_BUILD__MYSQL="--with-mysql-config=<path/to/mysql_config>" bundle config
# ...

build.mysql
Set via BUNDLE_BUILD__MYSQL: "--with-mysql-config=<path/to/mysql_config>"

Keep reading

  • Working with Bundler

Feedback

Log in to submit feedback.

Managing Gems with Bundler Bundler Version Considerations

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices