Skip to content

Commit

Permalink
Merge pull request #18259 from Homebrew/silence-default-gems-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid authored Sep 5, 2024
2 parents 2e18b02 + eb5f476 commit dfe28d8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
5 changes: 1 addition & 4 deletions Library/Homebrew/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
require "api/analytics"
require "api/cask"
require "api/formula"
require "warnings"
Warnings.ignore :default_gems do
require "base64" # TODO: Add this to the Gemfile or remove it before moving to Ruby 3.4.
end
require "base64" # TODO: vendor this for Ruby 3.4.

module Homebrew
# Helper functions for using Homebrew's formulae.brew.sh API.
Expand Down
5 changes: 1 addition & 4 deletions Library/Homebrew/dev-cmd/contributions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ def time_period(from:, to:)

sig { params(totals: T::Hash[String, T::Hash[Symbol, Integer]]).returns(String) }
def generate_csv(totals)
require "warnings"
Warnings.ignore :default_gems do
require "csv"
end
require "csv" # TODO: this will be removed from Ruby 3.4

CSV.generate do |csv|
csv << %w[user repo author committer coauthor review total]
Expand Down
12 changes: 12 additions & 0 deletions Library/Homebrew/standalone/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,15 @@
$LOAD_PATH.unshift "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle/#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/" \
"bundler-#{Homebrew::HOMEBREW_BUNDLER_VERSION}/lib"
$LOAD_PATH.uniq!

# These warnings are nice but often flag problems that are not even our responsibly,
# including in some cases from other Ruby standard library gems.
# We strictly only allow one version of Ruby at a time so future compatibility
# doesn't need to be handled ahead of time.
if defined?(Gem::BUNDLED_GEMS)
[Kernel.singleton_class, Kernel].each do |kernel_class|
next unless kernel_class.respond_to?(:no_warning_require, true)

kernel_class.alias_method :require, :no_warning_require
end
end
6 changes: 0 additions & 6 deletions Library/Homebrew/warnings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ module Warnings
parser_syntax: [
%r{warning: parser/current is loading parser/ruby\d+, which recognizes},
/warning: \d+\.\d+\.\d+-compliant syntax, but you are running \d+\.\d+\.\d+\./,
# FIXME: https://github.com/errata-ai/vale/issues/818
# <!-- vale off -->
%r{warning: please see https://github\.com/whitequark/parser#compatibility-with-ruby-mri\.},
# <!-- vale on -->
],
default_gems: [
/warning: .+\.rb was loaded from the standard library, .+ default gems since Ruby \d+\.\d+\.\d+\./,
],
}.freeze

Expand Down

0 comments on commit dfe28d8

Please sign in to comment.