Skip to content

Commit a57e8ae

Browse files
committed
Update test harness for Bundler 1.16 compatibility
This commit fixes Travis failures due to the recent introduction of Bundler 1.16.0. Both are related to the new style of binstubs that are generated by 1.16.0. First, add `bundler` to the list of binstubs that we explicitly generate when creating the test Rails app. The `bin/bundle` binstub that ships as part of `rails new` is in the pre-1.16 format, and conflicts with the 1.16 format binstubs that are generated for rake and rspec. Fix this by replacing the default `bin/bundle` with a fresh one generated by `bundle binstubs bundler --force`. Second, the `Bundle.with_clean_env` wrapper seems to remove some important information from the environment that causes binstubs to fail with errors like `uninitialized constant Gem (NameError)`. Fix this by using `Bundle.with_original_env` instead (which is what the Bundler documentation recommends). Because Travis also sets its own `BUNDLER_GEMFILE` variable, I had to also reset that one manually.
1 parent 0e24322 commit a57e8ae

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Rakefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace :generate do
6565
in_example_app do
6666
sh "./travis_retry_bundle_install.sh 2>&1"
6767
# Rails 4 cannot use a `rails` binstub generated by Bundler
68-
sh "bundle binstubs rspec-core rake --force"
68+
sh "bundle binstubs bundler rspec-core rake --force"
6969
sh "bundle binstubs railties" unless File.exist?("bin/rails")
7070

7171
application_file = File.read("config/application.rb")
@@ -93,7 +93,8 @@ def in_example_app(*command_opts)
9393
app_dir = opts.fetch(:app_dir, app_dir)
9494
end
9595
Dir.chdir(app_dir) do
96-
Bundler.with_clean_env do
96+
Bundler.with_original_env do
97+
ENV["BUNDLE_GEMFILE"] = "Gemfile"
9798
sh *command_opts unless command_opts.empty?
9899
yield if block_given?
99100
end
@@ -187,7 +188,7 @@ namespace :no_active_record do
187188
in_example_app(:app_dir => example_app_dir) do
188189
sh "./travis_retry_bundle_install.sh 2>&1"
189190
# Rails 4 cannot use a `rails` binstub generated by Bundler
190-
sh "bundle binstubs rspec-core rake --force"
191+
sh "bundle binstubs bundler rspec-core rake --force"
191192
sh "bundle binstubs railties" unless File.exist?("bin/rails")
192193

193194
application_file = File.read("config/application.rb")

0 commit comments

Comments
 (0)