mas: [BUG] Uninstall using sudo always fails the first time

Describe the bug It’s a known limitation that the uninstall must be run using sudo. However, it always fails with the message “Error: Not installed” the first time the command is run using sudo. 2nd time seems to work fine.

$ mas info 883878097
macOS Server 5.7.1 [19.99]
By: Apple Inc.
Released: Sep 28, 2018
Minimum OS: 10.14
Size: 106.5 MB
From: https://itunes.apple.com/us/app/macos-server/id883878097?mt=12&uo=4

$ mas uninstall 883878097 --dry-run
==> Server /Applications/Server.app
==> (not removed, dry run)

$ mas uninstall 883878097
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 883878097
Password:
Error: Not installed

$ sudo mas uninstall 883878097
==> App moved to trash: /private/var/root/.Trash/Server.app

To Reproduce Steps to reproduce the behavior:

  1. Run mas uninstall 883878097 --dry-run to verify app (macOS Server) is installed
  2. Run sudo mas uninstall 883878097
  3. See error
  4. Run sudo mas uninstall 883878097 again
  5. Observe success

Expected behavior The first time the sudo mas uninstall 883878097 command is ran it should succeed.

Actual behavior sudo mas uninstall 883878097 fails. It must be run a 2nd time.

Desktop (please complete the following information):

  • mas version 1.6.2
  • macOS version: 10.14.3
  • How did you install mas? brew

Additional context The uninstall command was added in 1.5.0 (#191)

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 10
  • Comments: 17 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I do have the very same issue and can’t uninstall anything even on the nth attempt:

gimli in ~ $ mas version
1.8.2

gimli in ~ $ mas list
430255202   Mactracker                (7.10.7)
883878097   Server                    (5.11.1)
425264550   Disk Speed Test           (3.3)
764936294   Purple Tree               (3.3.4)
...

gimli in ~
2969 $ sudo mas uninstall 883878097
Error: Not installed

gimli in ~
2970 $ sudo mas uninstall 883878097
Error: Not installed

gimli in ~ $ sudo mas uninstall 883878097
Error: Not installed

gimli in ~ $ sudo mas uninstall 883878097
Error: Not installed

gimli in ~ $ sudo mas uninstall 883878097
Error: Not installed

gimli in ~ $ sudo mas uninstall 883878097
Error: Not installed

I also have this same issue no matter how many times I use sudo… Seriously I can’t mas uninstall <id> and there’s no way to remove it from mas list

Same with macOS 13.1 22C65 arm64

Using AppCleaner to uninstall did work though.

For me it would be enough in a first step that I can remove items from the list that are not installed anymore. Otherwise they end up in my brewfile when dumping my env.

Using “AppCleaner” worked for me.