Skip to content
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

[Feature Request] Ability to uninstall mas applications. #81

Closed
aaranmcguire opened this issue Mar 16, 2017 · 5 comments
Closed

[Feature Request] Ability to uninstall mas applications. #81

aaranmcguire opened this issue Mar 16, 2017 · 5 comments

Comments

@aaranmcguire
Copy link

I'd like the ability to uninstall/remove applications installed via the mac app store, this would be useful to remove the default applications that are installed when purchasing a new mac (Keynote, Pages, etc).

@CNG
Copy link

CNG commented Mar 26, 2017

I am a bit shocked there is no uninstall option! … But I guess the Mac App Store itself does not have an uninstall.

@timsutton
Copy link
Contributor

Apple has never provided a method for uninstalling MAS applications besides the "X" button you can bring up in LaunchPad, or just moving the application to the trash.

Because MAS applications are self-contained into a single app bundle, one can make the argument that their removal is trivial compared to applications which come in (often messily-organized) installer packages which run code to place files anywhere on the filesystem.

What does add a complication to uninstalling MAS apps, however, is that you must be root to remove them. LaunchPad's removal interface uses some internal Apple magic to not require an admin password, but you'll see a password prompt if you attempt to delete a MAS-installed app from /Applications.

@CNG
Copy link

CNG commented Mar 27, 2017

My current somewhat hacky solution for uninstalling items from a Brewfile involves using the trash utility to delete the MAS apps, so there will be a prompt for password. (Perhaps my implementation is a bit strange… learning Bash.)

trash_file () {
  local item=$1
  if [[ -d $item || -f $item ]]; then
    echo "Trashing $item"
    if test ! $(which trash); then
      brew install trash
      trash "$item"
      brew uninstall trash
    else
      trash "$item"
    fi
  fi
}

# Uninstall packages from manifests, named Brewfile
local manifest=Brewfile #local, because this is excerpt from a function
if [[ -f $manifest ]]; then
  echo "Checking for manifest packages to remove."
  cat "$manifest" | tr -s " " | # squash spaces and pass to loop
  {
    while read -r line; do
      line=${line%,*} # keep up to first comma
      line=${line//\'/} # hope package names don't contain single quotes
      line=${line//\"/} # hope package names don't contain double quotes
      case $line in
        '#'* ) ;; # ignore comments
        'brew '* ) brew uninstall "${line#brew }" ;;
        'cask '* ) brew cask uninstall "${line#cask }" ;;
        'mas '*  ) trash_file "/Applications/${line#mas }.app" ;;
        * ) echo "Unsure how to handle line: $line" ;;
      esac
    done
  }
fi

@kernelsmith
Copy link

++ on this feature, helps a lot when using Brewfile + mas to setup new macs

@phatblat phatblat added this to the 1.5 milestone Dec 27, 2018
@phatblat
Copy link
Member

This feature is now available in mas 1.5.0. Thanks for the suggestion, @aaranmcguire!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants