BUNDLE_WITHOUT
not working with development
group
10 Aug 2021 in TIL
Given the following Gemfile
which installs rspec
as both a test
and development
dependency:
ruby
source "https://rubygems.org"group :test, :development dogem "rspec"end
Running BUNDLE_WITHOUT="test" bundle install
will still install rspec
- why?
bash
❯ BUNDLE_WITHOUT="test" bundle installUsing bundler 1.17.2Using diff-lcs 1.4.4Using rspec-support 3.10.2Using rspec-core 3.10.1Using rspec-expectations 3.10.1Using rspec-mocks 3.10.2Using rspec 3.10.0Bundle complete! 1 Gemfile dependency, 7 gems now installed.Gems in the group test were not installed.Bundled gems are installed into `./vendor/bundle`
Setting the
BUNDLE_WITHOUT
environment variable is equivalent to runningbundle install --without test
It turns out that BUNDLE_WITHOUT
must match all groups, not any groups. You can provide multiple groups by adding a colon between them like so:
bash
❯ BUNDLE_WITHOUT="test:development" bundle installUsing bundler 1.17.2Bundle complete! 1 Gemfile dependency, 1 gem now installed.Gems in the groups test and development were not installed.Bundled gems are installed into `./.vendor/bundle`
The solution here is to provide both groups to BUNDLE_WITHOUT
or only put your dependencies in a single group.