buo / homebrew-cask-upgrade

A command line tool for upgrading every outdated app installed by Homebrew Cask
MIT License
2.44k stars 90 forks source link

When an application fails due to permissions, it is unlinked from Cask. #149

Closed syntholly closed 4 years ago

syntholly commented 4 years ago

Issue

When using brew cu -fa on a list of ~30 applications, one or two tend to have permission problems. dropbox is a consistent culprit.

Setup

I'm using zsh (with oh-my-zsh) and don't have a particularly complicated $PATH. I don't mess with the permissions for the folders brew dances with either. Other than that, I'm using iTerm2 and running Mojave with the latest zsh, brew and homebrew-cask-upgrade.

Log

cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Resources/DropboxMacUpdate.app/Contents/Frameworks/CrashReporter.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Resources/DropboxMacUpdate.app/Contents/Frameworks/CrashReporter.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Resources/DropboxMacUpdate.app/Contents/Frameworks/CrashReporter.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Resources/DropboxMacUpdate.app/Contents/Frameworks/CrashReporter.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/A/Frameworks/Chromium Embedded Framework.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/A/Frameworks/Chromium Embedded Framework.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/A/Frameworks/Chromium Embedded Framework.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/A/Frameworks/Chromium Embedded Framework.framework/Versions/Current
cp: symlink: Versions/Current/Libraries: File exists
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxTransport.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxTransport.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxTransport.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxTransport.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxNucleus.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxNucleus.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxNucleus.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxNucleus.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxCrashpad.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxCrashpad.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxCrashpad.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxCrashpad.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxApex.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxApex.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxApex.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxApex.framework/Versions/Current
==> Purging files for version latest of Cask dropbox
Error: Failure while executing; `cp -pR /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/. /usr/local/Caskroom/dropbox/latest/Dropbox.app` exited with 1. Here's the output:
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Resources/DropboxMacUpdate.app/Contents/Frameworks/CrashReporter.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Resources/DropboxMacUpdate.app/Contents/Frameworks/CrashReporter.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Resources/DropboxMacUpdate.app/Contents/Frameworks/CrashReporter.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Resources/DropboxMacUpdate.app/Contents/Frameworks/CrashReporter.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/A/Frameworks/Chromium Embedded Framework.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/A/Frameworks/Chromium Embedded Framework.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/A/Frameworks/Chromium Embedded Framework.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/A/Frameworks/Chromium Embedded Framework.framework/Versions/Current
cp: symlink: Versions/Current/Libraries: File exists
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/Tungsten.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxTransport.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxTransport.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxTransport.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxTransport.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxNucleus.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxNucleus.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxNucleus.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxNucleus.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxCrashpad.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxCrashpad.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxCrashpad.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxCrashpad.framework/Versions/Current
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxApex.framework/Resources with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxApex.framework/Resources
cp: cannot overwrite directory /usr/local/Caskroom/dropbox/latest/Dropbox.app/./Contents/Frameworks/DropboxApex.framework/Versions/Current with non-directory /var/folders/p_/0gr6mnqx6b79q6b1z1vb4_w80000gn/T/d20200107-32799-xvc5b4/Dropbox.app/./Contents/Frameworks/DropboxApex.framework/Versions/Current

Follow the instructions here:
  https://github.com/Homebrew/homebrew-cask#reporting-bugs
/usr/local/Homebrew/Library/Homebrew/system_command.rb:176:in `assert_success!'
/usr/local/Homebrew/Library/Homebrew/system_command.rb:53:in `run!'
/usr/local/Homebrew/Library/Homebrew/system_command.rb:29:in `run'
/usr/local/Homebrew/Library/Homebrew/system_command.rb:33:in `run!'
/usr/local/Homebrew/Library/Homebrew/system_command.rb:19:in `system_command!'
/usr/local/Homebrew/Library/Homebrew/unpack_strategy/directory.rb:21:in `block in extract_to_dir'
/usr/local/Homebrew/Library/Homebrew/unpack_strategy/directory.rb:20:in `each'
/usr/local/Homebrew/Library/Homebrew/unpack_strategy/directory.rb:20:in `extract_to_dir'
/usr/local/Homebrew/Library/Homebrew/unpack_strategy.rb:123:in `extract'
/usr/local/Homebrew/Library/Homebrew/unpack_strategy.rb:143:in `block in extract_nestedly'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
/usr/local/Homebrew/Library/Homebrew/unpack_strategy.rb:127:in `extract_nestedly'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:193:in `extract_primary_container'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:73:in `stage'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:97:in `install'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/install.rb:22:in `block in run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/install.rb:16:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/install.rb:16:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/abstract_command.rb:36:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:92:in `run_command'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:158:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:123:in `run'
/usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:9:in `cask'
/usr/local/Homebrew/Library/Homebrew/brew.rb:102:in `<main>'

After that failure, brew cu won't list the application and brew cask list won't show the application anymore either. The application is sometimes still 'installed' but other times it has not been - I haven't looked at the actual /Applications/**/* files but Spotlight won't find some after the error.

I am not using a sudo or similar, I'm just on the only account. I thought it might be an issue only on my work machine but it's happening on a fresh-install personal machine too.

Happy to chase any details up.

Workaround Fix

I'm currently just taking screenshots and a mental note of how many applications were installed before. I'll then just do a reinstall brew cask install dropbox --force for example.

ondrejfuhrer commented 4 years ago

Hello @vSanjo, thank you for your extensive report.

I was able to reproduce the problem and proposed a fix to our process. Unfortunately that is not fixing the installation of the cask itself (that is not our responsibility here), so I would recommend raising that issues as well in the Homebrew Cask project, maybe someone will be able to help there.

But at least after the fix is merged the cask should stay in the "installed" state and should not disappear any more.

ondrejfuhrer commented 4 years ago

@vSanjo I just merged the change so you can test it. Feel free to reopen the issue if that doesn't work for you 🙂

syntholly commented 4 years ago

Thanks for you help, @ondrejfuhrer!

With the new version, is there a particular process to follow or will it homebrew-cask-upgrade update itself?

ondrejfuhrer commented 4 years ago

Hey @vSanjo , should be automatic, if you run brew update (which should be run automatically) you can see in the output something like this:

Updated 3 taps (homebrew/core, homebrew/cask and buo/homebrew-cask-upgrade)

Which indicates that it was updated to the latest version.