Skip to content

/flags/bundler/bundle-config-without

bundle install --without development test: skip Gemfile groups (bundle config set without)

The commands on this page have not been executed by our verification runner yet.updated
tool
Bundler
command
bundle install
flag
--without GROUPS (deprecated); bundle config set without GROUPS; BUNDLE_WITHOUT
default
every group of the Gemfile is installed

bundle install --without development test was the classic way to skip Gemfile groups on a production server. The flag was deprecated in Bundler 2 because Bundler silently remembered it in .bundle/config; the current bundle install reference no longer lists it. The replacement is the without setting: bundle config set --local without "development test" or, without writing any file, the environment variable BUNDLE_WITHOUT="development:test". Gems in those groups are not installed, and Bundler.setup does not try to load them.

Commands

bash
# Old style (deprecated)
bundle install --without development test

# Current style
bundle config set --local without "development test"
bundle install

# Environment variable (Docker, CI); colon- or space-separated
BUNDLE_WITHOUT="development:test" bundle install

# Undo
bundle config unset --local without

Group settings

SettingEffect
without (BUNDLE_WITHOUT)Skip the listed groups
with (BUNDLE_WITH)Install the listed groups, including groups marked optional: true
only (BUNDLE_ONLY)Install only the listed groups (add default for ungrouped gems)
group :x, optional: true in the GemfileGroup skipped unless named in with
bundle config listShow the active settings and where they come from

Resolution still includes every group

Bundler resolves the complete Gemfile even when groups are excluded, and the reference explains why: installing a different set of groups on a production server must not change the versions you developed and tested against. A gem in an excluded group therefore still constrains the versions of shared dependencies, and it still has to be resolvable.

In code

ruby
# config/application.rb in Rails
Bundler.require(*Rails.groups)

Rails loads only the groups for the current environment. Gems from excluded groups are not installed, so requiring them in production code fails with a LoadError; keep production code free of development-only gems.

Pitfalls

  • A setting stored with --local lives in .bundle/config of the checkout and affects every later command there, which is exactly the surprise the deprecation was meant to avoid. In containers prefer BUNDLE_WITHOUT.
  • Running a development tool in production through bundle exec fails when its group was excluded, sometimes as Could not find gem in locally installed gems.
  • Combine with deployment for production installs; see bundle install --deployment.

FAQ

Why does Bundler still download gems of excluded groups?

Bundler resolves the whole Gemfile, including excluded groups, so production uses exactly the versions you developed and tested with. It does not install those gems, but it needs their specifications to resolve.

How do I install a group again after excluding it?

Remove the setting with bundle config unset without (add --local if you set it locally) or override it with bundle config set --local with development, then run bundle install.

What is the difference between without and only?

without lists groups to skip; everything else is installed. only lists the groups to install; gems without an explicit group belong to the default group, so include default (only test:default) if you need them.

Sources