diff options
| author | Max Howell | 2012-03-19 00:15:40 +0000 |
|---|---|---|
| committer | Max Howell | 2012-03-19 00:28:38 +0000 |
| commit | ce082c167cba9e5df3c95e429ec510da8a29fa19 (patch) | |
| tree | a34b89569b6d25a325382605a5e815ac86707c0f /Library/Homebrew/extend | |
| parent | 45d78a84e6789239e2e95a516d7237bcf2fedcc6 (diff) | |
| download | homebrew-ce082c167cba9e5df3c95e429ec510da8a29fa19.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.rb | 11 |
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 |
