aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorJack Nagel2012-08-19 00:33:35 -0500
committerJack Nagel2012-08-19 12:04:44 -0500
commit35e32f352d84c53fb93d4e9a9227d757ec1d5508 (patch)
tree830e067a2d12912c9e65dbd4e376a7058546f07c /Library/Homebrew
parentc6b3cd7cf454d542f0d713472a4cea73746d57a2 (diff)
downloadbrew-35e32f352d84c53fb93d4e9a9227d757ec1d5508.tar.bz2
factory: don't reload previously defined formulae
build.rb calls Formula.factory to get a usable Formula object to pass to its install method. However, because the formula file is the actual executing script, its class is already defined, and loading it again causes the class to be re-evaluated, which, unfortunately, is not idempotent. This bug has existed for a very long time, and its side effects include duplicate entries the deps array and mirrors array, among others. Fortunately, the fix is very simple. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/formula.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 57e5f76de..773b6d746 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -377,20 +377,22 @@ class Formula
else
name = Formula.canonical_name(name)
# If name was a path or mapped to a cached formula
- if name.include? "/"
- require name
+ if name.include? "/"
# require allows filenames to drop the .rb extension, but everything else
# in our codebase will require an exact and fullpath.
name = "#{name}.rb" unless name =~ /\.rb$/
path = Pathname.new(name)
name = path.stem
+
+ require path unless Object.const_defined? self.class_s(name)
+
install_type = :from_path
target_file = path.to_s
else
# For names, map to the path and then require
- require Formula.path(name)
+ require Formula.path(name) unless Object.const_defined? self.class_s(name)
install_type = :from_name
end
end