Homebrew / homebrew-cask

🍻 A CLI workflow for the administration of macOS applications distributed as binaries
https://brew.sh
BSD 2-Clause "Simplified" License
20.9k stars 10.7k forks source link

Amethyst won't uninstall/reinstall under macOS Mojave #55711

Closed todd-a-jacobs closed 5 years ago

todd-a-jacobs commented 5 years ago

General troubleshooting steps

Description of issue

Amethyst can't be removed or reinstalled. It reports:

36:84: execution error: Not authorized to send Apple events to System Events. (-1743)

Command that failed

brew cask uninstall amethyst

Output of command with --force --verbose --debug

$ brew cask uninstall --force --verbose --debug amethyst
==> Uninstalling Cask amethyst
==> Uninstalling Cask amethyst
==> Un-installing artifacts
==> 3 artifact/s defined
#<SortedSet:0x00007fdb9d3ac430>
==> Un-installing artifact of class Cask::Artifact::Uninstall
==> Running uninstall process for amethyst; your password may be necessary
==> Removing login item Amethyst
osascript -e tell\ application\ \"System\ Events\"\ to\ delete\ every\ login\ item\ whose\ name\ is\ \"Amethyst\"
36:84: execution error: Not authorized to send Apple events to System Events. (-1743)
Error: Failure while executing; `osascript -e tell\ application\ \"System\ Events\"\ to\ delete\ every\ login\ item\ whose\ name\ is\ \"Amethyst\"` exited with 1. Here's the output:
36:84: execution error: Not authorized to send Apple events to System Events. (-1743)

Follow the instructions here:
  https://github.com/Homebrew/homebrew-cask#reporting-bugs
/usr/local/Homebrew/Library/Homebrew/system_command.rb:107:in `assert_success'
/usr/local/Homebrew/Library/Homebrew/system_command.rb:50:in `run!'
/usr/local/Homebrew/Library/Homebrew/system_command.rb:27:in `run'
/usr/local/Homebrew/Library/Homebrew/system_command.rb:31:in `run!'
/usr/local/Homebrew/Library/Homebrew/system_command.rb:17:in `system_command!'
/usr/local/Homebrew/Library/Homebrew/cask/artifact/abstract_uninstall.rb:211:in `block in uninstall_login_item'
/usr/local/Homebrew/Library/Homebrew/cask/artifact/abstract_uninstall.rb:209:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/artifact/abstract_uninstall.rb:209:in `uninstall_login_item'
/usr/local/Homebrew/Library/Homebrew/cask/artifact/abstract_uninstall.rb:60:in `block in dispatch_uninstall_directives'
/usr/local/Homebrew/Library/Homebrew/cask/artifact/abstract_uninstall.rb:56:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/artifact/abstract_uninstall.rb:56:in `dispatch_uninstall_directives'
/usr/local/Homebrew/Library/Homebrew/cask/artifact/uninstall.rb:7:in `uninstall_phase'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:429:in `block in uninstall_artifacts'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/set.rb:674:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/set.rb:674:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:425:in `uninstall_artifacts'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:380:in `uninstall'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/uninstall.rb:22:in `block in run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/uninstall.rb:12:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/uninstall.rb:12:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/abstract_command.rb:34:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:89:in `run_command'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:155:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:120:in `run'
/usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:7:in `cask'
/usr/local/Homebrew/Library/Homebrew/brew.rb:89:in `<main>'
Error: Kernel.exit
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:166:in `exit'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:166:in `rescue in run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:143:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:120:in `run'
/usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:7:in `cask'
/usr/local/Homebrew/Library/Homebrew/brew.rb:89:in `<main>'

Output of brew cask doctor

==> Homebrew Version
1.8.4-25-gc89f6c8
==> macOS
10.14.1
==> SIP
Enabled
==> Java
11.0.1, 1.8.0_66, 1.8.0_60
==> Gatekeeper support
Enabled
==> Homebrew Cask Install Location
<NONE>
==> Homebrew Cask Staging Location
/usr/local/Caskroom
==> Homebrew Cask Taps:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask (4070 casks)
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions (209 casks)
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-fonts (1185 casks)
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-drivers (159 casks)
==> Contents of $LOAD_PATH
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/ruby-macho-2.1.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/rubocop-rspec-1.30.1/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/rubocop-0.60.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/unicode-display_width-1.4.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/ruby-progressbar-1.10.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/rainbow-3.0.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/powerpack-0.1.2/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/plist-3.4.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/parser-2.5.3.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/parallel-1.12.1/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/jaro_winkler-1.5.1/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/jaro_winkler-1.5.1
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/backports-3.11.4/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/ast-2.4.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/activesupport-5.2.1/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/tzinfo-1.2.5/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/thread_safe-0.3.6/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/minitest-5.11.3/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/i18n-1.1.1/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle-standalone/bundler/../ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib
/Library/Ruby/Gems/2.3.0/gems/did_you_mean-1.0.0/lib
/Library/Ruby/Site/2.3.0
/Library/Ruby/Site/2.3.0/x86_64-darwin18
/Library/Ruby/Site/2.3.0/universal-darwin18
/Library/Ruby/Site
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby/2.3.0
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby/2.3.0/x86_64-darwin18
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby/2.3.0/universal-darwin18
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/x86_64-darwin18
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18
/usr/local/Homebrew/Library/Homebrew
==> Environment Variables
LC_ALL="en_US.UTF-8"
PATH="/usr/local/Homebrew/Library/Homebrew/shims/scm:/usr/bin:/bin:/usr/sbin:/sbin"
SHELL="/usr/local/bin/bash"

Output of brew tap

$ brew tap
heroku/brew
homebrew/cask
homebrew/cask-drivers
homebrew/cask-fonts
homebrew/cask-versions
homebrew/core
vitorgalvao commented 5 years ago

You need to give something authorisation. I’m not on Mojave yet so I’m not entirely sure what it needs to be, but it might just be the Terminal, or bash, or brew. You were supposed to get a system dialog.

Go to System Preferences → Security & Privacy → Automation to grant permission.

todd-a-jacobs commented 5 years ago

Why This is Still a Bug

Amethyst is already installed, and already has control permissions: screen shot 2018-12-04 at 12 03 25 pm

What was missing was system events permissions for Terminal. System Events access is turned off by default, and this being the issue is not at all obvious from Homebrew's output. Granted that the tool throwing the error is oascript, if this is a known problem then it needs to be either:

  1. Documented within homebrew.
  2. Trapped by brew and a more sensible error returned.

There's nothing in the error message or other output clearly tying this to Terminal, so the fact that Homebrew doesn't handle this more gracefully is (in my opinion) still a bug. YMMV.

The User-Enabled Permissions Fix

screen shot 2018-12-04 at 12 11 53 pm

This certainly resolves the problem, and allows a clean uninstall of Amethyst. However, formulae that rely on oascript (and perhaps other newly-locked aspects of Mojave) really ought to trap those errors better.

vitorgalvao commented 5 years ago

Amethyst is already installed, and already has control permissions What was missing was system events permissions for Terminal.

Which is exactly what I said.

if this is a known problem

It was a problem for you. Mojave is the one handling this and it should have shown you a dialog. A ton of casks rely on AppleScript on uninstall, and yet this isn’t a common issue. If Mojave didn’t ask for your permissions, either you had denied it before or it was a bug with macOS. If you dislike the system as is (and it is indeed deeply flawed), you need to complain to Apple.

formulae

Casks. They’re different things.

really ought to trap those errors better.

The error was indicated just fine. Had you done a web search for the message, you’d immediately have found the cause and the fix. There’s only so much handholding we can do.