aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorMax Howell2012-03-19 00:15:40 +0000
committerMax Howell2012-03-19 00:28:38 +0000
commitc3370c48ce3ec6d00387e427413e46ca65d585d8 (patch)
treea2a5a616c2431ed147dc36771694a47fd9ccbd2f /Library/Homebrew/extend
parent8088f6c17b7ab7cdd8f46d3422ae080f844dbaf0 (diff)
downloadbrew-c3370c48ce3ec6d00387e427413e46ca65d585d8.tar.bz2
Better error when linking fails
Refs http://stackoverflow.com/questions/9762943 The system ln no longer outputs anything. Though the user can force its output with a --verbose of course. So in cases where it's not the usual of: not writable or existing file, we can ask the user to run with --verbose. I don't particularly like hiding its output, but it just confused the error IMO since it is creating a relative symlink the output was weird every time I've seen it in tickets. I made a print wrapper so that the brew-link output doesn't get mucked up if an exception is thrown.
Diffstat (limited to 'Library/Homebrew/extend')
-rw-r--r--Library/Homebrew/extend/pathname.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 1ccbff51c..7412fd157 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -283,9 +283,14 @@ class Pathname
self.dirname.mkpath
Dir.chdir self.dirname do
# NOTE only system ln -s will create RELATIVE symlinks
- system 'ln', '-s', src.relative_path_from(self.dirname), self.basename
- # ln outputs useful error message for us
- raise "Could not create symlink: #{to_s}." unless $?.success?
+ quiet_system 'ln', '-s', src.relative_path_from(self.dirname), self.basename
+ if not $?.success?
+ raise <<-EOS.undent
+ Could not symlink file: #{src.expand_path}
+ Check #{self} does not already exist.
+ Check #{dirname} is writable.
+ EOS
+ end
end
end