Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formulary: fix error with absolute alias paths #13888

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions Library/Homebrew/formulary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ def self.loader_for(ref, from: nil)
return TapLoader.new(ref, from: from)
end

return FromPathLoader.new(ref) if File.extname(ref) == ".rb" && Pathname.new(ref).expand_path.exist?
pathname_ref = Pathname.new(ref)
return FromPathLoader.new(ref) if File.extname(ref) == ".rb" && pathname_ref.expand_path.exist?

if Homebrew::EnvConfig.install_from_api?
return FormulaAPILoader.new(ref) if Homebrew::API::Formula.all_formulae.key?(ref)
Expand All @@ -680,8 +681,12 @@ def self.loader_for(ref, from: nil)
formula_with_that_name = core_path(ref)
return FormulaLoader.new(ref, formula_with_that_name) if formula_with_that_name.file?

possible_alias = core_alias_path(ref)
return AliasLoader.new(possible_alias) if possible_alias.file?
possible_alias = if pathname_ref.absolute?
pathname_ref
else
core_alias_path(ref)
end
return AliasLoader.new(possible_alias) if possible_alias.symlink?

possible_tap_formulae = tap_paths(ref)
raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae) if possible_tap_formulae.size > 1
Expand Down