Skip to content

Commit 11f418f

Browse files
Use --quiet for bundle install
When generating a new app, `bundle install` may be run multiple times due to various application templates. This can create a lot of noise in the output log, particularly with Bundler <= 2.4.16, which displays the full list of gems each time `bundle install` is run. To reduce noise, this commit adds the `--quiet` flag to `bundle install` commands. __Before__ ```console $ rails new my_cool_app --dev create create Gemfile run bundle install Resolving dependencies... Fetching gem metadata from https://rubygems.org/.......... Bundle complete! 1 Gemfile dependency, 58 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. run rails new my_cool_app --dev exist remove Gemfile remove Gemfile.lock create README.md ... run bundle install Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... Bundle complete! 12 Gemfile dependencies, 78 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. ... rails importmap:install apply importmap-rails-1.2.3/lib/install/install.rb ... run bundle install Bundle complete! 12 Gemfile dependencies, 78 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. rails turbo:install stimulus:install apply turbo-rails-1.5.0/lib/install/turbo_with_importmap.rb ... run bundle install Bundle complete! 12 Gemfile dependencies, 78 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. apply turbo-rails-1.5.0/lib/install/turbo_needs_redis.rb Enable redis in bundle gsub Gemfile run bundle install Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... Bundle complete! 13 Gemfile dependencies, 80 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. Switch development cable to use redis gsub config/cable.yml run bundle install Bundle complete! 13 Gemfile dependencies, 80 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. apply stimulus-rails-1.3.0/lib/install/stimulus_with_importmap.rb ... run bundle install Bundle complete! 13 Gemfile dependencies, 80 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. ``` __After__ ```console $ rails new my_cool_app --dev create create Gemfile run bundle install --quiet run rails new my_cool_app --dev exist remove Gemfile remove Gemfile.lock create README.md ... run bundle install --quiet ... rails importmap:install apply importmap-rails-1.2.3/lib/install/install.rb ... run bundle install --quiet rails turbo:install stimulus:install apply turbo-rails-1.5.0/lib/install/turbo_with_importmap.rb ... run bundle install --quiet apply turbo-rails-1.5.0/lib/install/turbo_needs_redis.rb Enable redis in bundle gsub Gemfile run bundle install --quiet Switch development cable to use redis gsub config/cable.yml run bundle install --quiet apply stimulus-rails-1.3.0/lib/install/stimulus_with_importmap.rb ... run bundle install --quiet ``` Note that `bundle install` still displays any errors when using the `--quiet` flag: ```console $ bundle install Could not find gem 'rails (= 9001.0)' in rubygems repository https://rubygems.org/ or installed locally. The source contains the following gems matching 'rails': * rails-0.8.0 ... * rails-7.1.2 ```
1 parent e85e574 commit 11f418f

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

railties/lib/rails/generators/app_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def target_rails_prerelease(self_command = "new")
680680
end
681681

682682
def run_bundle
683-
bundle_command("install", "BUNDLE_IGNORE_MESSAGES" => "1") if bundle_install?
683+
bundle_command("install --quiet", "BUNDLE_IGNORE_MESSAGES" => "1") if bundle_install?
684684
end
685685

686686
def run_javascript

railties/test/generators/app_generator_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def test_generation_runs_bundle_install
680680
generator([destination_root])
681681
run_generator_instance
682682

683-
assert_equal 1, @bundle_commands.count("install")
683+
assert_not_empty @bundle_commands.grep(/^install/)
684684
end
685685

686686
def test_generation_runs_bundle_lock_for_linux

railties/test/generators/plugin_generator_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def test_no_duplicate_gemfile_entries_when_using_prerelease
244244
end
245245
end
246246

247-
def test_generation_runs_bundle_install
247+
def test_generation_does_not_run_bundle_install
248248
generator([destination_root])
249249
run_generator_instance
250250

railties/test/generators/shared_generator_tests.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ def run_generator_using_prerelease(args)
414414
end
415415

416416
assert_file File.expand_path("Gemfile", project_path) do |gemfile|
417-
assert_equal "install", prerelease_commands[0]
417+
assert_match %r/^install/, prerelease_commands[0]
418418
assert_equal gemfile[rails_gem_pattern], prerelease_command_rails_gems[0]
419419

420-
assert_match %r"^exec rails (?:plugin )?new #{Regexp.escape Shellwords.join(expected_args)}", prerelease_commands[1]
420+
assert_match %r/^exec rails (?:plugin )?new #{Regexp.escape Shellwords.join(expected_args)}/, prerelease_commands[1]
421421
assert_equal gemfile[rails_gem_pattern], prerelease_command_rails_gems[1]
422422
end
423423
end

0 commit comments

Comments
 (0)