cask doctor: fix for non-standard installation location in ~

Symptom (relevant portions):
```
$ brew cask doctor
==> Homebrew-Cask Version
Homebrew-Cask 1.6.7-56-g9ebcef7
Homebrew/homebrew-cask (git revision fc24e; last commit 2018-06-09)
==> macOS
10.13.5
==> SIP
Enabled
...
==> Homebrew-Cask Install Location
<NONE>
==> Homebrew-Cask Staging Location
~/homebrew/Caskroom
...
==> Environment Variables
HOMEBREW_CASK_OPTS="--appdir=~/Applications"
LC_ALL="en_US.UTF-8"
PATH="/usr/bin:/bin:/usr/sbin:/sbin:~/homebrew/Library/Homebrew/shims/scm"
SHELL="/bin/bash"
Cask's Doctor Checkup: failed
 - The staging path ~/homebrew/Caskroom does not exist.
Error: There are some problems with your setup.
```

Analysis:

* The source code is
  [this](9ebcef785e/Library/Homebrew/cask/lib/hbc/cli/doctor.rb (L63-L66)).

* The issue is reproducible in `brew irb`:

```
$ ls -dl ~/homebrew/Caskroom
drwxrwxr-x  10 luca  admin  340  9 Jun 16:22 /Users/luca/homebrew/Caskroom
$ ( cd ~ && pwd; )
/Users/luca
$ ls -dl /Users/luca/homebrew/Caskroom
drwxrwxr-x  10 luca  admin  340  9 Jun 16:22 /Users/luca/homebrew/Caskroom
$ brew irb
==> Interactive Homebrew Shell
Example commands available with: brew irb --examples
irb(main):001:0> Pathname.new("~/homebrew/Caskroom").exist?
=> false
irb(main):002:0> Pathname.new("/Users/luca/homebrew/Caskroom").exist?
=> true
```
This commit is contained in:
Luca Favatella 2018-06-09 23:50:32 +01:00
parent cac30f6186
commit ece34dbe26

View File

@ -60,13 +60,13 @@ module Hbc
def check_staging_location
ohai "Homebrew-Cask Staging Location"
path = Pathname.new(user_tilde(Caskroom.path.to_s))
path = Caskroom.path
if path.exist? && !path.writable?
add_error "The staging path #{path} is not writable by the current user."
add_error "The staging path #{user_tilde(path.to_s)} is not writable by the current user."
end
puts path
puts user_tilde(path.to_s)
end
def check_cached_downloads