mas: šŸ› [BUG] mas uninstall does not work on macOS 11.1

Your Environment

  • mas version: 1.7.1
  • macOS version: 11.1

mas Install Method

  • brew install mas (homebrew-core)

Describe the Bug

mas uninstall [id] complains it needs root permissions to uninstall but sudo mas uninstall [id] says the app is not installed.

To Reproduce

Steps to reproduce the behavior:

  1. Install an app; mas install [id]
  2. Uninstall the app with sudo mas uninstall [id]

Expected Behavior

Moves the app to the Trash Bin

Actual Behavior

It will say: Error: not installed

Screenshots, Terminal Output

image

Additional Context

None

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 23
  • Comments: 16

Commits related to this issue

Most upvoted comments

Works with sudo -s if that helps anyone, but things end up in root’s trash:

==> App moved to trash: /private/var/root/.Trash/Telegram.app

same issue on:

  • macOS 12.0.1 (21A559)
  • mas 1.8.5
mas uninstall 408981434 
Warning: Apps installed from the Mac App Store require root permission to remove.
Error: Unable to move app to trash.
Error: Uninstall failed
sudo mas uninstall 408981434
Error: Not installed
sudo -s mas uninstall 408981434
Error: Not installed
mas list
408981434   iMovie      (10.2.5)

So mas hasn’t had an uninstall function in 3 years?

It’s a permission issue related to macOS’s security sandbox : When you use sudo, the command is ran with root privileges and in the root environment, but doesn’t have access to your user-specific App Store data. This is why the mas command is unable to see the installed apps and uninstall them. You can verify this by running mas list (will show your apps) and sudo mas list (will be empty).

To fix this, I’m afraid we’ll need something like a Privileged Helper Tool (https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/AccessControl.html#//apple_ref/doc/uid/TP40007244-SW5). A working example of this can be found under ā€œEvenBetterAuthorizationSampleā€.

Unfortunately I’m not experienced with Swift, otherwise I’d look into this, but that’s basically what’s going on.

(related?: https://github.com/mas-cli/mas/issues/417)

Same issue here, my mas’ version is 1.8.2 and macOS is 11.4.