buo / homebrew-cask-upgrade

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

Can't uninstall cask after download start #163

Closed yurikoles closed 3 years ago

yurikoles commented 4 years ago

I often encounter that a large cask that I don't plan to use will be upgraded. But uninstalling cask after it's download started is seems to be impossible.

iHack~(:|✔) % brew cu -ay
==> Options
Include auto-update (-a): true
Include latest (-f): false
==> Updating Homebrew
Already up-to-date.
<...>
==> Found outdated apps
     Cask                       Current       Latest        A/U    Result    
1/2  virtualbox                 6.1.6,137129  6.1.8,137981       [OUTDATED]  
2/2  virtualbox-extension-pack  6.1.6         6.1.8              [OUTDATED]  

==> Upgrading virtualbox to 6.1.8,137981
==> Caveats
virtualbox requires a kernel extension to work.
If the installation fails, retry after you enable it in:
  System Preferences → Security & Privacy → General

For more information, refer to vendor documentation or this Apple Technical Note:
  https://developer.apple.com/library/content/technotes/tn2459/_index.html

==> Downloading https://download.virtualbox.org/virtualbox/6.1.8/VirtualBox-6.1.
###                                                                        4.8%^C

iHack~(:|✔) % brew cask uninstall virtualbox
Error: Cask 'virtualbox' is not installed.
ondrejfuhrer commented 4 years ago

Hey @yurikoles ,

Thanks for raising this. The problem is that you cancel the execution during installation. That leaves the metadata unsynced with the current state. It might be related to this: https://github.com/buo/homebrew-cask-upgrade/issues/57

We currently backup the metadata, then install the app itself and then if the installation was successful, delete the "old" metadata. If the installation fails, then we restore the backed-up metadata so that it works fine afterwards.

When you cancel the installation it ends up in a state when there are no metadata for the app even though it is installed and therefore brew cask doesn't know that it is installed.

I hope that make sense.

ondrejfuhrer commented 3 years ago

Hey @yurikoles

After I changed the installation mechanism from a custom one to using reinstall command, this doesn't seem to an issue any more.

Feel free to reopen the issue if you still encounter this.