diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index e2875794a7..cb69767ebb 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -583,14 +583,11 @@ then # Don't allow non-developers to customise Ruby warnings. unset HOMEBREW_RUBY_WARNINGS - - # Disable Ruby options we don't need. - RUBY_DISABLE_OPTIONS="--disable=did_you_mean,rubyopt" -else - # Don't disable did_you_mean for developers as it's useful. - RUBY_DISABLE_OPTIONS="--disable=rubyopt" fi +# Disable Ruby options we don't need. +RUBY_DISABLE_OPTIONS="--disable=rubyopt" + if [[ -z "${HOMEBREW_RUBY_WARNINGS}" ]] then export HOMEBREW_RUBY_WARNINGS="-W1" diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index a1806c4b24..7d1f18d03a 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2,6 +2,7 @@ # frozen_string_literal: true require "cache_store" +require "did_you_mean" require "formula_support" require "lock_file" require "formula_pin" @@ -1671,6 +1672,13 @@ class Formula CoreTap.instance.alias_reverse_table end + # Returns a list of approximately matching formula names, but not the complete match + # @private + def self.fuzzy_search(name) + @spell_checker ||= DidYouMean::SpellChecker.new(dictionary: Set.new(names + full_names).to_a) + @spell_checker.correct(name) + end + def self.[](name) Formulary.factory(name) end diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 99d0081059..810a9ea474 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -127,6 +127,7 @@ class Tap @style_exceptions = nil @pypi_formula_mappings = nil @config = nil + @spell_checker = nil remove_instance_variable(:@private) if instance_variable_defined?(:@private) end