mas icon indicating copy to clipboard operation
mas copied to clipboard

Warn & document that `uninstall` requires your terminal/sshd to have Full Disk Access & be able to automate Finder

Open RixzZ opened this issue 1 year ago • 14 comments

Your Environment

  • mas version: 1.8.7
  • macOS version (system_profiler SPSoftwareDataType -detailLevel mini): macOS 14.7 (23H124)

mas Install Method

brew install mas (homebrew-core)

Describe the Bug

When trying to uninstall apps (previously installed from the GUI, if that matters somehow), it errors with the following:

Error: Runtime Error: Failed to revert ownership of deleted '/Applications/GarageBand.app' back to uid 501 & gid 20: delete result did not have a URL

To Reproduce

  1. Execute sudo mas uninstall 682658836.
  2. Provide password if requested.

Expected Behavior

It should be able to uninstall it.

Actual Behavior

It errors out and apparently does nothing to the app.

Screenshots, Terminal Output

$ sudo mas uninstall 682658836
Error: Runtime Error: Failed to revert ownership of deleted '/Applications/GarageBand.app' back to uid 501 & gid 20: delete result did not have a URL

Additional Context

I don't know if it worked in a previous version. Just started using 'mas'.

RixzZ avatar Nov 14 '24 14:11 RixzZ

@RixzZ Did the app get moved to the trash, or did it remain under /Applications?

rgoldberg avatar Nov 14 '24 16:11 rgoldberg

It's still in /Applications.

RixzZ avatar Nov 14 '24 16:11 RixzZ

@RixzZ was the app running while you uninstalled it?

Apps are deleted by using a scripting bridge to Finder. The actual delete process is fairly opaque. No errors could have been thrown, the Finder delete() function doesn't seem to have deleted the app folder for you, and the object returned by that function didn't have a file URL for the app folder since it wasn't deleted.

Since deletion works for me (albeit on a different version on macOS), it will be hard to investigate this without being able to reproduce it somewhere where I can debug, or without learning about reflection-like capabilities of Swift to output more info in this circumstance for you to send to me after running it.

Will get to this in a bit due to other more pressing issues.

rgoldberg avatar Nov 15 '24 16:11 rgoldberg

No... in fact, I don't think it was ever opened since it was installed.

Also, the error thrown it's instant. It doesn't seem to do much before throwing it.

This Mac it updated with Open Core to a version not officially supported by that hardware (2014 Mac Mini). I didn't detect any limitation with any software (Apple's or 3rd Party), so I don't think it matters, but anyway, just in case.

RixzZ avatar Nov 15 '24 18:11 RixzZ

Thanks for info.

A successful uninstall should also be fairly instantaneous.

Will probably be a while before I can get to investigating this.

rgoldberg avatar Nov 15 '24 18:11 rgoldberg

I have the same problem. I executed sudo mas uninstall 682658836 via iTerm2 and there was a pop-up asking something like giving permission to Finder.app… lost in other thoughts, I reflexively canceled without really reading it 🙄 And now I've that error message (Error: Runtime Error: Failed to revert ownership of deleted '/Applications/GarageBand.app' back to uid 501 & gid 20: delete result did not have a URL).

Any idea how to give iTerm2 that permission?

ppo avatar Feb 07 '25 11:02 ppo

@ppo You must check the checkbox at:

macOS 13+:

System Settings -> Privacy & Security -> Automation -> (the name of your terminal app; iTerm2.app for @ppo) -> Finder.app

macOS 12-:

System Properties -> Security & Privacy -> Privacy -> Automation -> (the name of your terminal app; iTerm2.app for @ppo) -> Finder.app

@ppo @RixzZ Does the above fix your problem?

rgoldberg avatar Feb 07 '25 12:02 rgoldberg

@rgoldberg Thanks. Now the app is deleted but there's still the Failed to revert ownership of deleted error.

ppo avatar Feb 07 '25 13:02 ppo

@ppo can you let me know what user owns the deleted app in the Trash? I assume it's owned by your normal user instead of by root. (It should be owned by root).

If that's the situation, then maybe you need to give Full Disk Access to iTerm2. Similar to "Automation", but choose "Full Disk Access" instead of "Automation".

Does that fix it for you?

rgoldberg avatar Feb 07 '25 13:02 rgoldberg

@rgoldberg I had already emptied the trash so I don't know who owned the file in Trash.

Weird, iTerm2 didn't have Full Disk Access (on my new install).
The app is now correctly deleted (moved into Trash).
The perms in ~/.Trash are drwxr-xr-x@ 3 root wheel.

ppo avatar Feb 07 '25 13:02 ppo

@ppo All good now?

rgoldberg avatar Feb 07 '25 13:02 rgoldberg

@rgoldberg Yes, all good. Thank you!

ppo avatar Feb 07 '25 14:02 ppo

@ppo You must check the checkbox at:

macOS 13+ (please let me know if instructions are incorrect, as I'm on macOS 12):

System Settings -> Privacy & Security -> Automation -> (the name of your terminal app; iTerm2.app for @ppo) -> Finder.app

macOS 12-:

System Properties -> Security & Privacy -> Privacy -> Automation -> (the name of your terminal app; iTerm2.app for @ppo) -> Finder.app

@ppo @RixzZ Does the above fix your problem?

I'll try next time I'm on the testing computer.

Either way, that might be able to make it work on local issued commands. In the setup I was working on, I'm using an Ansible playbook with the 'mas' module and executing it remotely through SSH.

I don't think that the permissions of the Terminal app would matter when remotely connected. Maybe I need to add another process (sshd maybe) to that list.

RixzZ avatar Feb 07 '25 15:02 RixzZ

It might make sense to output to stderr instructions about setting permissions whenever the error occurs. Will revisit in the future.

rgoldberg avatar Apr 09 '25 13:04 rgoldberg