bundler environment variables

Here are some environment variables that bundler uses. This is only the bundler-specific variables. I’m leaving out other environment variables, like RUBYOPT or PATH, that bundler uses, but that are used by other things on the system, too. There is a partial list in the bundle-config man page.

Some of the values are accessed through Bundler::Settings. Any values accessed there can be set in a local (./.bundle/config) or global (~/.bundle/config) settings file. The order of precedence is: local, environment, global.

Incidentally, while looking through bundler 1.1.1’s code, I learned that you can trigger whether to load a particular gem with environment variables. So, for example, if you say gem 'debugger', :env => 'USE_DEBUGGER', it only loads the debugger gem if USE_DEBUGGER is set; or, if you say gem 'debugger', :env => { 'USE_DEBUGGER' => 'yes' }, then it only loads the debugger gem if USE_DEBUGGER is set to yes.

Variable Description Source reference
BUNDLER_EDITOR editor to use for commands like bundle open, defaults to $VISUAL or $EDITOR.) bundler/cli.rb
BUNDLE_APP_CONFIG path to directory where bundler stores local configuration, defaults to ./bundle/config bundler.rb
BUNDLE_BIN_PATH   bundler/rubygems_integration.rb, bundler/runtime.rb
BUNDLE_BIN (settings[:bin])   bundler.rb, bundler/installer.rb
BUNDLE_CLEAN (settings[:clean]) Run bundle clean during bundle install and bundle update bundler/cli.rb
BUNDLE_CONFIG global bundler settings file, defaults to ~/.bundle/config bundler/settings.rb
BUNDLE_DISABLE_SHARED_GEMS (settings[:disable_shared_gems]) if set, bundle won’t use shared (system) gems bundler.rb
BUNDLE_FROZEN (settings[:frozen]) used internally bundler/cli.rb, bundler/definition.rb, bundler/installer.rb
BUNDLE_GEMFILE path to the gemfile bundler/cli.rb, bundler/runtime.rb, bundler/shared_helpers.rb
BUNDLE_NO_PRUNE (settings[:no_prune]) Don’t remove stale gems from the cache bundler/cli.rb, bundler/runtime.rb
BUNDLE_PATH (settings.path or settings[:path]) where bundler should install your gems, defaults to the shared (system) gem path bundler/settings.rb, bundler/cli.rb, bundler/installer.rb
BUNDLE_SPEC_RUN used in bundler’s tests bundler/shared_helpers.rb
BUNDLE_SYSTEM_BINDIR (settings[:system_bindir]) overridden gem binstub directory, similar to -n in .gemrc bundler.rb
BUNDLE_WITHOUT (settings.without) list of groups to exclude, :-separated bundler/cli.rb, bundler/definition.rb
DEBUG, DEBUG_RESOLVER outputs debug logs bundler/resolver.rb, bundler/setup.rb, bundler/ui.rb