-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uninstall
does not work on macOS 11.1+
#313
Comments
I'm seeing the same issue on MAS 1.7.1 on macOS 11.2 |
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. |
Works with
|
Same issue here, my |
Same in BS 11.6 and mas 1.8.3. Uninstall not working, says "not installed". |
same issue on:
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) |
Same issue for me:
Any new on what's causing this? sudo -s doesn't sove it! |
Also an issue for me on |
Same here! |
Macos 12.6.4 (21G511) |
I'm not a Swift programmer but I'm guessing something in this function has changed? public func run(_ options: Options) -> Result<Void, MASError> {
|
Still won't work because of mas-cli/mas#313 but maybe it is fixed somehow in the future ...
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 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?: #417) |
So mas hasn't had an uninstall function in 3 years? |
Still having the same issue
|
You could have fixed it all along yet here we are 🙃
I don't think this is the only issue, you can run things with root as your regular user with I'm wondering what's the issue, I haven't inspected the code, but can't we just What am I missing? |
uninstall
does not work on macOS 11.1+
The problem is occurring because an earlier part of the code must be run by a user whose associated Apple ID was used to install the app that you want to uninstall ( The folders & files on the file system for apps installed from the App Store (i.e. App Store apps) are owned by the The other option is to allow
Thus, I suggest requiring being called with To trash the app, we need to know the path to the app folder on the file system (e.g.,
If we don’t care about preventing users from uninstalling apps from other Apple IDs, we can try to find the app path without using the list lookup. That would avoid needing Unfortunately, the app ID does not seem to be deterministically findable from the files for an App Store app. The plists I’ve seen under App Store app folders do not include the app ID. Recursively greppjng for the app ID in an app’s files sometime shows it in a binary executable, but sometimes not. One extended attribute ( The bundle ID (which should be unique for each app), however, seems to be in If we do the above, we should allow the bundle ID to be passed as a command line argument (i.e. Or we could still use the app list provided by the Apple private framework to get the app path by switching from So, my best guess is:
Do people agree or disagree with this plan? |
@rgoldberg I've got to agree your solution seems the most elegant for the problem. Obviously an update to the docs and man pages would need to be done 😄 |
@jacoboneill Thanks. I assume I would start just fixing uninstall to work with app ID, then later I'd implement bundle IDs as command line arguments for all appropriate commands at once, just so we could get uninstall fixed a bit faster. I'm working on some other simpler issues first. I am also hoping to get in touch with some other project members before making larger changes like this, but I might work on this if I don't hear back from others soon. |
@chris-araman provided some details about elevated-privilege solutions here: #216 (comment) |
Hello, I wanted to share my workaround that others may use in the meantime. It is not without issues, but it works for me very well! I am trying to bootstrap my new laptop, and just wanted to declare exactly which mas apps should be installed. Part of doing that requires removing ones that are not declared. Expand for workaround script
❯ mas list | awk '{print $1}'
682658836
408981434
1501592214 # twingate
409201541
409183694
6446206067 # slack
409203825 ^ In my case, twingate and slack are installed on purpose. The rest are apple defaults I don't want (Garage Band, Pages, etc.)
❯ (mas list | awk '{print $1}'; \
echo -e "6446206067\n1501592214") | sort | uniq -u
408981434
409183694
409201541
409203825
682658836
❯ (mas list | awk '{print $1}'; \
echo -e "6446206067\n1501592214") | sort | uniq -u \
| xargs -I {} sudo mas uninstall {}
Error: Not installed # x5 whoops! #313
❯ (mas list | awk '{print $1}'; \
echo -e "6446206067\n1501592214") | sort | uniq -u \
| xargs -I {} curl -s -X GET "https://itunes.apple.com/lookup?id={}" \
| jq -r '.results[0].bundleId'
com.apple.iMovieApp
com.apple.iWork.Keynote
com.apple.iWork.Pages
com.apple.iWork.Numbers
com.apple.garageband10
❯ (mas list | awk '{print $1}'; \
echo -e "6446206067\n1501592214") | sort | uniq -u \
| xargs -I {} curl -s -X GET "https://itunes.apple.com/lookup?id={}" \
| jq -r '.results[0].bundleId' \
| xargs -I {} mdfind "kMDItemCFBundleIdentifier == '{}'"
/Applications/iMovie.app
/Applications/Keynote.app
/Applications/Pages.app
/Applications/Numbers.app
/Applications/GarageBand.app ^ the benefit of using ...Oooooof. But if you have a Cask installed with
❯ (mas list | awk '{print $1}'; \
echo -e "6446206067\n1501592214") | sort | uniq -u \
| xargs -I {} curl -s -X GET "https://itunes.apple.com/lookup?id={}" \
| jq -r '.results[0].bundleId' \
| xargs -I {} mdfind "kMDItemCFBundleIdentifier == '{}'" \
| xargs -I {} sudo rm -rf {}
❯ (mas list | awk '{print $1}'; \
echo -e "6446206067\n1501592214" ) | sort | uniq -u \
| parallel -j $(nproc) '
# Fetch the bundleId using iTunes API
bundleId=$(curl -s -X GET "https://itunes.apple.com/lookup?id={}" \
| jq -r ".results[0].bundleId");
# Find the application path using mdfind
appPath=$(mdfind "kMDItemCFBundleIdentifier == \"$bundleId\"");
# Uninstall the app if found
if [ -n "$appPath" ]; then
echo "Uninstalling $appPath...";
sudo rm -rf "$appPath";
# Optionally clean up support files
sudo rm -rf ~/Library/Preferences/"$bundleId".plist;
sudo rm -rf ~/Library/Caches/"$bundleId";
sudo rm -rf ~/Library/Application\ Support/"$bundleId";
else
echo "App not found for ID {}";
fi
' Thank you, @rgoldberg, for providing the detailed write up of how to do this. I never would have thought of this. Also, I feel guilty not mentioning bots wrote most the GNU Parallel code |
@xav-i.e. Thanks. To simplify your workaround, you can use I'll use |
Partial mas-cli#313 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
because multiple installed apps can have the same app ID or app name. Partial mas-cli#313 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
Partial mas-cli#313 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
Improve errors. Simplify code. Partial mas-cli#313 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
Partial mas-cli#313 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
Resolve mas-cli#313 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
Your Environment
mas Install Method
brew install mas
(homebrew-core)Describe the Bug
mas uninstall [id]
complains it needs root permissions to uninstall butsudo mas uninstall [id]
says the app is not installed.To Reproduce
Steps to reproduce the behavior:
mas install [id]
sudo mas uninstall [id]
Expected Behavior
Moves the app to the Trash Bin
Actual Behavior
It will say: Error: not installed
Screenshots, Terminal Output
Additional Context
The text was updated successfully, but these errors were encountered: