Merge pull request #4320 from lucafavatella/brew-cask-doctor
Fix `brew cask doctor` for non-standard installation location
This commit is contained in:
commit
c814199a79
@ -60,13 +60,13 @@ module Hbc
|
|||||||
def check_staging_location
|
def check_staging_location
|
||||||
ohai "Homebrew-Cask Staging Location"
|
ohai "Homebrew-Cask Staging Location"
|
||||||
|
|
||||||
path = Pathname.new(user_tilde(Caskroom.path.to_s))
|
path = Caskroom.path
|
||||||
|
|
||||||
if path.exist? && !path.writable?
|
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
|
end
|
||||||
|
|
||||||
puts path
|
puts user_tilde(path.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_cached_downloads
|
def check_cached_downloads
|
||||||
@ -165,11 +165,6 @@ module Hbc
|
|||||||
Formatter.error("(#{string})")
|
Formatter.error("(#{string})")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.render_with_none(string)
|
|
||||||
return string if !string.nil? && string.respond_to?(:to_s) && !string.to_s.empty?
|
|
||||||
none_string
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.alt_taps
|
def self.alt_taps
|
||||||
Tap.select { |t| t.cask_dir.exist? && t != Tap.default_cask_tap }
|
Tap.select { |t| t.cask_dir.exist? && t != Tap.default_cask_tap }
|
||||||
end
|
end
|
||||||
@ -181,16 +176,6 @@ module Hbc
|
|||||||
"0"
|
"0"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.render_taps(*taps)
|
|
||||||
taps.collect do |tap|
|
|
||||||
if tap.path.nil? || tap.path.to_s.empty?
|
|
||||||
none_string
|
|
||||||
else
|
|
||||||
"#{tap.path} (#{cask_count_for_tap(tap)})"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.render_env_var(var)
|
def self.render_env_var(var)
|
||||||
return unless ENV.key?(var)
|
return unless ENV.key?(var)
|
||||||
var = %Q(#{var}="#{ENV[var]}")
|
var = %Q(#{var}="#{ENV[var]}")
|
||||||
@ -201,46 +186,6 @@ module Hbc
|
|||||||
path.gsub(ENV["HOME"], "~")
|
path.gsub(ENV["HOME"], "~")
|
||||||
end
|
end
|
||||||
|
|
||||||
# This could be done by calling into Homebrew, but the situation
|
|
||||||
# where "doctor" is needed is precisely the situation where such
|
|
||||||
# things are less dependable.
|
|
||||||
def self.render_install_location
|
|
||||||
locations = Dir.glob(HOMEBREW_CELLAR.join("brew-cask", "*")).reverse
|
|
||||||
if locations.empty?
|
|
||||||
none_string
|
|
||||||
else
|
|
||||||
locations.collect do |l|
|
|
||||||
"#{l} #{error_string 'error: legacy install. Run "brew uninstall --force brew-cask".'}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.render_staging_location(path)
|
|
||||||
path = Pathname.new(user_tilde(path.to_s))
|
|
||||||
if !path.exist?
|
|
||||||
"#{path} #{error_string "error: path does not exist"}"
|
|
||||||
elsif !path.writable?
|
|
||||||
"#{path} #{error_string "error: not writable by current user"}"
|
|
||||||
else
|
|
||||||
path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.render_load_path(paths)
|
|
||||||
paths.map(&method(:user_tilde))
|
|
||||||
return "#{none_string} #{error_string}" if [*paths].empty?
|
|
||||||
paths
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.render_cached_downloads
|
|
||||||
cleanup = CLI::Cleanup.new
|
|
||||||
count = cleanup.cache_files.count
|
|
||||||
size = cleanup.disk_cleanup_size
|
|
||||||
msg = user_tilde(Cache.path.to_s)
|
|
||||||
msg << " (#{number_readable(count)} files, #{disk_usage_readable(size)})" unless count.zero?
|
|
||||||
msg
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.help
|
def self.help
|
||||||
"checks for configuration issues"
|
"checks for configuration issues"
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user