From fbc16426603bc226b02597ef0dd0b479b7dd0cd2 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Wed, 22 Apr 2026 21:01:01 +0000 Subject: [PATCH] Yes, use bundle exec inside Rakefile --- Rakefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 1455c171..572b6354 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,4 @@ begin - require "bundler/setup" require "bundler/gem_tasks" require "minitest/test_task" require "rdoc/task" @@ -29,12 +28,18 @@ task default: %i[test rubocop:autocorrect] namespace :test do desc "Run tests for all supported Rails versions, with current Ruby version" task :all do + # I _think_ we have to run `bundle exec rake...` here. But that doesn't mean we have + # to run `bundle exec rake...` when we're just running commands in the shell. + # I believe this is because `rake` will load some gems, and the tests, depending on + # the Rails version, may need to load conflicting versions of the gems. + # When you run a single test in the shell, it hasn't had the intermediate `rake` task + # to load gems, so the problem doesn't arise there. gemfiles.each do |gemfile| - system("BUNDLE_GEMFILE=#{gemfile} rake test") + system("BUNDLE_GEMFILE=#{gemfile} bundle exec rake test") end Dir.chdir("demo") - system("BUNDLE_GEMFILE= rake test:all") + system("bin/rails test:all") end end