mas-cli / mas

:package: Mac App Store command line interface
MIT License
10.84k stars 273 forks source link

🐛 [BUG] Installed apps not found when running commands from Shortcuts app #532

Closed LouisRoselli closed 4 weeks ago

LouisRoselli commented 1 month ago

Your Environment

mas Install Method

Describe the Bug

Running "mas" commands in Shortcuts app's "Run Shell Script" action is not detecting any installed apps on the system when running these commands:

Command Results
mas list "No installed apps found"
mas outdated BLANK
mas upgrade "Warning: Nothing found to upgrade"

To Reproduce

You can use this link to get a copy of the shortcut instead of manually creating one: https://www.icloud.com/shortcuts/25b3da7ce04b467bb75dc83dbd4b631c

Steps to reproduce the behavior:

  1. Go to Shortcuts app.
  2. Click on '+' at the top of the app to create a new shortcut.
  3. In the shortcut, add an action called "Run Shell Script"
  4. Set the following:
    1. PATH=$PATH:/opt/homebrew/bin
      mas list
    2. Shell: "zsh"
    3. Input: "Input"
    4. Pass Input: "to stdin"
    5. Run as Administrator: checked
  5. Add an action called "Show Result" after the previous action and set the "Shell Script Result" as the output.
  6. Repeat Steps 3-5 for commands "mas outdated" and "mas upgrade".

Expected Behavior

I expected a list of apps to show like the results from Terminal. I expected a list of outdated apps to show like the results from Terminal. I expected outdated apps to upgrade and show like the results from Terminal.

Actual Behavior

Got an output of "No installed apps found". Got an output of "". Got an output of "Warning: Nothing found to upgrade".

Screenshots, Terminal Output

mas-shortcuts-issue-1 mas-shortcuts-issue-2 mas-shortcuts-issue-3 mas-shortcuts-issue-4 mas-shortcuts-issue-5
rgoldberg commented 4 weeks ago

Uncheck Run as Administrator.

sudo mas list, not mas list, is the same as Run as Administrator.

e.g.:

$ sudo mas list
Password:
Error: No installed apps found

$ mas list
497799835   Xcode                     (14.2)
…
LouisRoselli commented 4 weeks ago

AND I'm dumb lol! Unchecking the "Run as administrator" fixed it. I think I originallly had it checked because of the full disk access permissions being weird.