aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorRobert Buonpastore2014-05-26 17:14:55 -0400
committerJack Nagel2014-06-08 11:07:49 -0500
commitc3541d8450b2cb9e93aacc7431d88f129f85116f (patch)
treebab1585612ed797c44d803a877978ac2e2e6f049 /Library
parent02c20132af6554429513ce64b40cabe7b41e1120 (diff)
downloadhomebrew-c3541d8450b2cb9e93aacc7431d88f129f85116f.tar.bz2
ruby: Fix mutually dependent links edge-case
Fixes #28759. Closes #29600. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/ruby.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/Library/Formula/ruby.rb b/Library/Formula/ruby.rb
index d60472fd3..49fbd82e7 100644
--- a/Library/Formula/ruby.rb
+++ b/Library/Formula/ruby.rb
@@ -62,16 +62,21 @@ class Ruby < Formula
end
def post_install
- # Put gem, site and vendor folders in the HOMEBREW_PREFIX
+ # Preserve gem, site, and vendor folders on upgrade/reinstall
+ # by placing them in HOMEBREW_PREFIX and sym-linking
ruby_lib = HOMEBREW_PREFIX/"lib/ruby"
- (ruby_lib/'site_ruby').mkpath
- (ruby_lib/'vendor_ruby').mkpath
- (ruby_lib/'gems').mkpath
-
- rm_rf Dir["#{lib}/ruby/{site_ruby,vendor_ruby,gems}"]
- (lib/'ruby').install_symlink ruby_lib/'site_ruby',
- ruby_lib/'vendor_ruby',
- ruby_lib/'gems'
+
+ ["gems", "site_ruby", "vendor_ruby"].each do |name|
+ link = lib/"ruby"/name
+ real = ruby_lib/name
+
+ # only overwrite invalid (mutually dependent) links
+ real.unlink if real.symlink? && real.readlink == link
+ real.mkpath
+
+ link.unlink if link.exist?
+ link.symlink real
+ end
end
def caveats; <<-EOS.undent