mas-cli / mas

:package: Mac App Store command line interface
MIT License
10.95k stars 275 forks source link

🐛 [BUG] mas keeps trying to upgrade Microsoft Remote Desktop to Windows App #632

Closed dan-gill closed 3 weeks ago

dan-gill commented 3 weeks ago

Your Environment

mas Install Method

Describe the Bug

mas reports that Microsoft Remote Desktop needs an upgrade when running mas outdated and will attempt to upgrade it repeatedly when running mas upgrade. mas list lists Windows App and Microsoft Remote Desktop.

To Reproduce

Steps to reproduce the behavior:

  1. Have old Microsoft Remote Desktop installed.
  2. Run mas outdated to see that an update is available to Windows App.
  3. Run mas upgrade
  4. Run mas outdated again and see that it offers to upgrade again. Repeat loop.

Expected Behavior

Perhaps it is due to the name change of the app, but I expect it should update the list so that Microsoft Remote Desktop becomes Windows App.

Actual Behavior

A ghost entry is listed in mas for the old version of the app that was previously installed before mas upgraded to the new version.

Screenshots, Terminal Output

image

image
$ mas upgrade
$ mas list

Additional Context

Link to previous issue thread.

rgoldberg commented 3 weeks ago

@dan-gill

It's possible that an extra copy of the application is in a subfolder of /Applications.

Please look for extra copies in every subfolder of /Applications, which can be done with the following zsh command:

\ls -d1 /Applications/(^*.app/)#*(Windows|Microsoft)*(D/)

If you don't find duplicates that way:

mas obtains the list of apps from an Apple data structure from a private framework. We filter it to ensure that we only deal with apps under /Applications. Our code for mas list shouldn't duplicate, add, filter, etc. any apps other than the aforementioned /Applications path filter.

mas currently doesn't have good debugging output. That will be provided in a forthcoming release, but will involve a complete rewrite of our output code.

In the meantime, it's easiest to debug via Xcode. Are you familiar with development in Xcode?

If so, could you fork mas, clone it, and open the project in Xcode 14.2 or newer?

Could you then either debug or just include more info in the mas list output?

1: Debug

Put a breakpoint in the for loop in AppListFormatter.format(products:), then debug mas passing list as the command-line argument via a scheme?

Find product.bundlePath wherever ["Windows App", "Microsoft Remote Desktop"].contains(product.appName).

Then share the product.bundlePaths you found.

The info is provided from Apple CKSoftwareProducts (defined in CKSoftwareProduct.h) wrapped by the mas SoftwareProduct protocol.

2: Output more info

Change the following line in the AppListFormatter.format(products:):

output += "\(appID)  \(appName)  (\(version))\n"

to be:

output += "\(appID)  \(appName)  (\(version))\n  \(product.bundlePath)"

Then run using list as an argument, then share the results.

dan-gill commented 3 weeks ago

@rgoldberg - I think there is something wrong with this command. ls -d1 /Applications/(^*.app/)#*(Windows|Microsoft)*(D/) When I use it, I get this error: zsh: bad pattern: /Applications/(^*.app/)#*(Windows|Microsoft)*(D/)

I am unfamiliar with Xcode for development.

rgoldberg commented 3 weeks ago

@dan-gill I forgot to mention that you must enable extended globbing for that to work. Run the following before the \ls … command:

setopt extendedglob

I enable extended globbing in my .zshrc, so I never need to manually enable it.

dan-gill commented 3 weeks ago

Thank you, here is the output:

image
rgoldberg commented 3 weeks ago

Can you try the following command lines?

\ls -dA /Applications/Windows\ App.app/Contents/MacOS 

\ls -d1 /Applications/**/*(Windows|Microsoft)*.app(D/)

The first will be quick as it just lists one folder's contents; the second might take some time as it searches under /Applications for any *.app folder whose name contains Windows or Microsoft.

dan-gill commented 3 weeks ago

That seemed a bit much for a screenshot, so here is the output:

❯ \ls -A /Applications/Windows\ App.app/Contents/MacOS
Windows App

❯ \ls -d1 /Applications/**/*(Windows|Microsoft)*.app(D/)
/Applications/Microsoft Defender.app
/Applications/Microsoft Defender.app/Contents/MacOS/Microsoft Defender Helper.app
/Applications/Microsoft Defender.app/Contents/MacOS/Microsoft Defender.app
/Applications/Microsoft Edge.app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.56/Helpers/Microsoft Edge Helper (Alerts).app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.56/Helpers/Microsoft Edge Helper (GPU).app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.56/Helpers/Microsoft Edge Helper (Plugin).app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.56/Helpers/Microsoft Edge Helper (Renderer).app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.56/Helpers/Microsoft Edge Helper.app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.68/Helpers/Microsoft Edge Helper (Alerts).app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.68/Helpers/Microsoft Edge Helper (GPU).app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.68/Helpers/Microsoft Edge Helper (Plugin).app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.68/Helpers/Microsoft Edge Helper (Renderer).app
/Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/130.0.2849.68/Helpers/Microsoft Edge Helper.app
/Applications/Microsoft Excel.app
/Applications/Microsoft Excel.app/Contents/SharedSupport/Microsoft Error Reporting.app
/Applications/Microsoft Excel.app/Contents/SharedSupport/Microsoft.Mashup.Container.app
/Applications/Microsoft OneNote.app
/Applications/Microsoft OneNote.app/Contents/SharedSupport/Microsoft Error Reporting.app
/Applications/Microsoft Outlook.app
/Applications/Microsoft Outlook.app/Contents/SharedSupport/Microsoft Error Reporting.app
/Applications/Microsoft PowerPoint.app
/Applications/Microsoft PowerPoint.app/Contents/SharedSupport/Microsoft Error Reporting.app
/Applications/Microsoft Teams.app
/Applications/Microsoft Teams.app/Contents/Helpers/Microsoft Teams ModuleHost.app
/Applications/Microsoft Teams.app/Contents/Helpers/Microsoft Teams WebView.app
/Applications/Microsoft Teams.app/Contents/Helpers/Microsoft Teams WebView.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/128.0.2739.75/Helpers/Microsoft Teams WebView Helper (GPU).app
/Applications/Microsoft Teams.app/Contents/Helpers/Microsoft Teams WebView.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/128.0.2739.75/Helpers/Microsoft Teams WebView Helper (Plugin).app
/Applications/Microsoft Teams.app/Contents/Helpers/Microsoft Teams WebView.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/128.0.2739.75/Helpers/Microsoft Teams WebView Helper (Renderer).app
/Applications/Microsoft Teams.app/Contents/Helpers/Microsoft Teams WebView.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/128.0.2739.75/Helpers/Microsoft Teams WebView Helper.app
/Applications/Microsoft Word.app
/Applications/Microsoft Word.app/Contents/SharedSupport/Microsoft Error Reporting.app
/Applications/OneDrive.app/Contents/Microsoft SharePoint.app
/Applications/Windows App.app
rgoldberg commented 3 weeks ago

I just realized that we can use a dry run of an uninstall to see the paths to the apps reported by mas:

sudo mas uninstall --dry-run 1295203466

This will NOT uninstall anything. sudo is required, though, even for a dry run.

And thanks for the prior command outputs. They obviously don't show any reason why Microsoft Remote Desktop would be showing up in the mas output.

dan-gill commented 3 weeks ago

Interesting:

image
rgoldberg commented 3 weeks ago

Is that an AWS server, or some other virtual server? This could be something weird from Amazon / some virtualization thing.

Can you try:

sudo ls -ld '/Applications/Microsoft Remote Desktop.app'

Is this an Apple Silicon or Intel? (it probably won't help me figure anything out, but…)

Also, maybe try to reset the Mac App Store services via:

mas reset --debug
rgoldberg commented 3 weeks ago

You could also try: on the Account page in App Store.app (accessible by clicking on the text at the bottom of the left pane that says the name of the Apple ID for which you're signed in in the Mac App Store), try to reload the page via the keyboard (Command-r) or via the menu (Store > Reload Page). Before you do that, check to see if Microsoft Remote Desktop is listed amongst your Purchased apps.

dan-gill commented 3 weeks ago

That is just part of my profile in ~/.aws/config for the AWS CLI. It lets me know which region I'm in when running AWS commands. I'm running this on my MacBook Pro - Apple Silicon.

image

You could also try: on the Account page in App Store.app (accessible by clicking on the text at the bottom of the left pane that says the name of the Apple ID for which you're signed in in the Mac App Store), try to reload the page via the keyboard (Command-r) or via the menu (Store > Reload Page). Before you do that, check to see if Microsoft Remote Desktop is listed amongst your Purchased apps.

This did the trick! However, I didn't read the entire post first and did not see the last sentence "Before you do that..."

rgoldberg commented 3 weeks ago

@dan-gill no problem.

Did you try mas reset --debug beforehand? If so, i assume that didn't solve the problem.

dan-gill commented 3 weeks ago

Yes, that is correct. I did everything in the order you listed.

rgoldberg commented 3 weeks ago

Cool. I assume the sudo ls … command didn't return any results, right?

dan-gill commented 3 weeks ago

Correct.

image
rgoldberg commented 3 weeks ago

@dan-gill Thanks for the info.

I'll close this issue since it seems to have been resolved.

I created #633, a new issue about implementing the equivalent of "Reload Page" in mas, if you feel like subscribing to that.

It'll probably be a while before we get to that as it will take research, and it might not be possible to do.