BUNDLE_WITHOUT not working with
10 Aug 2021 in TIL
Given the following
Gemfile which installs
rspec as both a
source "https://rubygems.org"group :test, :development dogem "rspec"end
BUNDLE_WITHOUT="test" bundle install will still install
rspec - why?
❯ 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`
BUNDLE_WITHOUTenvironment variable is equivalent to running
bundle 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:
❯ 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.