mas icon indicating copy to clipboard operation
mas copied to clipboard

`uninstall` does not work on macOS 11.1+

Open Sergong opened this issue 4 years ago • 23 comments

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

Sergong avatar Jan 17 '21 20:01 Sergong

I'm seeing the same issue on MAS 1.7.1 on macOS 11.2

endlesslycurious avatar Feb 02 '21 17:02 endlesslycurious

Same as @endlesslycurious; at least for the second part it seems like MAS is engineered so that when run as root with sudo (or su) it would look for app store installations by the root user, which would (normally) be none, as opposed to when run with normal user privileges. And macOS probably doesn't allow uninstallation of an app without root password at all... interesting quandary, not sure how you might fix it.

kabirbg avatar Feb 21 '21 01:02 kabirbg

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

philsherry avatar Mar 31 '21 13:03 philsherry

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

baggiponte avatar Jun 03 '21 09:06 baggiponte

Same in BS 11.6 and mas 1.8.3. Uninstall not working, says "not installed".

Stooovie avatar Oct 11 '21 18:10 Stooovie

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)

JanOwiesniak avatar Nov 23 '21 11:11 JanOwiesniak

Same issue

  • MacOS 11.5.2 (M1 Mac)
  • MAS 1.8.6 Screen Shot 2022-01-16 at 1 49 16 PM

carlfugate avatar Jan 16 '22 19:01 carlfugate

Same issue for me:

mas uninstall 897118787
Error: Not installed

Any new on what's causing this?

sudo -s doesn't sove it!

Drallas avatar Feb 03 '22 20:02 Drallas

MacOS 12.2.1 and still not working

image

whilestevego avatar Feb 27 '22 00:02 whilestevego

Also an issue for me on MAS 1.8.6 for Mac 12.4

njjerrysmith avatar Jun 03 '22 02:06 njjerrysmith

Same issue for me:

mas uninstall 897118787
Error: Not installed

Any new on what's causing this?

sudo -s doesn't sove it!

Same here!

yandongxu avatar Aug 02 '22 09:08 yandongxu

Macos 12.6.4 (21G511) Same here

tarikkavaz avatar Mar 09 '23 19:03 tarikkavaz

I'm not a Swift programmer but I'm guessing something in this function has changed? https://github.com/mas-cli/mas/blob/main/Sources/MasKit/Commands/Uninstall.swift

public func run(_ options: Options) -> Result<Void, MASError> { let appId = UInt64(options.appId)

    guard let product = appLibrary.installedApp(forId: appId) else {
        return .failure(.notInstalled)
    }

carlfugate avatar Mar 09 '23 21:03 carlfugate

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)

claudiodekker avatar Jul 20 '23 12:07 claudiodekker

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

BitGrub avatar Mar 17 '24 06:03 BitGrub

Still having the same issue

  • MAS Version: 1.8.6
  • Mac OS: 13.6.6

jacoboneill avatar Apr 04 '24 15:04 jacoboneill