Make sure we respect bundler config for Gemfile
What does this MR do?
Make sure we respect bundler config for Gemfile.
When we run bundle exec
, it'll go through: https://github.com/rubygems/rubygems/blob/v3.2.26/bundler/lib/bundler/cli.rb#L58-L60 namely:
custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
if custom_gemfile && !custom_gemfile.empty?
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", File.expand_path(custom_gemfile)
Bundler.reset_settings_and_root!
end
So it'll respect the config for Gemfile
in the bundle config. However, if we just require 'bundler/setup'
then the above code won't run and the config will be ignored.
This attempts to bring them aligned.
This change is tested at gitlab-jh/gitlab!89 (closed)
-
compile-test-assets
before: https://gitlab.com/gitlab-jh/gitlab/-/jobs/1556019024 -
compile-test-assets
after: https://gitlab.com/gitlab-jh/gitlab/-/jobs/1556953791 -
setup-test-env
before: https://gitlab.com/gitlab-jh/gitlab/-/jobs/1556019029 -
setup-test-env
after: https://gitlab.com/gitlab-jh/gitlab/-/jobs/1556953797
Considerations:
- Document this
- Add a Rubocop cop to detect
require 'setup/bundler'
because it'll not work with #338469 (closed)
Related to #339939 (closed)
Edited by Lin Jen-Shin