mas icon indicating copy to clipboard operation
mas copied to clipboard

Repeatedly upgrading to an older version of an app

Open JayaswalPrateek opened this issue 1 year ago • 22 comments

mas config

mas ▁▁▁▁ 1.9.0
arch ▁▁▁ arm64
from ▁▁▁ homebrew/core/mas
origin ▁ https://github.com/mas-cli/mas.git
rev ▁▁▁▁ a5a928a2e6a28a5c751bca7f63f26b06cede8197
driver ▁ 1.115
swift ▁▁ 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
region ▁ IN
macos ▁▁ 15.3 (24D60)
mac ▁▁▁▁ Mac14,2
cpu ▁▁▁▁ Apple M2

Bug description

Every time I run mas upgrade, it detects WhatsApp Messenger as outdated(25.1.10) and tries to update it to 25.1.83. Even after a successful update, it still finds it outdated in the next run. While the app itself never updates to 25.1.83 and stays on Version 25.1.10 (688756559), yet it detects it as outdated upon every single run and still tries to update it to 25.1.83 and tells it happened successful even though it didn't. It keeps installing the older version again and again on every run.

$ mas list | grep WhatsApp
310633997   ‎WhatsApp                         (25.1.10)

) mas upgrade
Upgrading 1 outdated application:
WhatsApp Messenger (25.1.10) -> (25.1.83)
==> Downloaded WhatsApp Messenger (25.1.10)
==> Installing WhatsApp Messenger (25.1.10)
==> Installed WhatsApp Messenger (25.1.10)

$ mas list | grep WhatsApp
310633997   ‎WhatsApp                         (25.1.10)

$ mas upgrade
Upgrading 1 outdated application:
WhatsApp Messenger (25.1.10) -> (25.1.83)
==> Downloaded WhatsApp Messenger (25.1.10)
==> Installing WhatsApp Messenger (25.1.10)
==> Installed WhatsApp Messenger (25.1.10)

$ mas list | grep WhatsApp
310633997   ‎WhatsApp                         (25.1.10)

Steps to reproduce

$ mas list | grep WhatsApp
$ mas upgrade
$ mas list | grep WhatsApp
$ mas upgrade
$ mas list | grep WhatsApp

JayaswalPrateek avatar Feb 04 '25 14:02 JayaswalPrateek

@JayaswalPrateek Thanks for the bug report.

The Apple private framework that mas uses to install & to upgrade apps is somehow choosing to install a version that isn't the latest.

I don't know why that is. There are multiple ways in which the Apple code used can be configured, but none of it is documented.

I might not be able to fix this for a while; if anyone else wants to investigate, the relevant code is in SSPurchase.swift. The entry point for mas upgrade is MAS.Upgrade.run() in Upgrade.swift, which makes calls that eventually call the functions in SSPurchase.swift.

You need to build using script/build to generate a file necessary for the build to work. Otherwise, if you just build in Xcode, you'll get errors.

rgoldberg avatar Feb 05 '25 04:02 rgoldberg

Thanks for the response @rgoldberg! Based on your previous experience with this framework, do you think there could be any dirty way to fix this issue? Like reinstalling that app or mas itself or maybe signing out from Mac app store and then signing back in? Any index/version files that can be deleted/regenerated?

JayaswalPrateek avatar Feb 05 '25 12:02 JayaswalPrateek

@JayaswalPrateek Unfortunately, besides updating the app directly using the App Store GUI application from Apple (instead of using mas), I do not know other solutions.

The integration with the relevant frameworks was done by someone else a long time ago.

I've looked into a few properties of SSPurchase before for other issues, but the variations of values that I tried didn't seem to have any effect for those issues, IIRC.

I have various notes about some info I've seen online & about my experiments, but I won't be able to find/collate them anytime soon.

There might be newer, better frameworks for mas to use, but I won't be able to look at them soon, either.

Sorry for the unsatisfactory answers.

I wish that I or someone else could look into it all right now.

rgoldberg avatar Feb 05 '25 13:02 rgoldberg

Is it related to https://github.com/Homebrew/homebrew-bundle/issues/1569?

$ mas list | grep WhatsApp
310633997   WhatsApp   (25.1.10)
$ mas list | grep WhatsApp | cat -v
310633997   �M-^@M-^NWhatsApp   (25.1.10)

moenodedev avatar Feb 06 '25 02:02 moenodedev

I noticed the same issue.

It also happens with other apps, as shown by "Latest" app: Image

Even if I remove WhatsApp and reinstall it from the AppStore, it still downloads 25.1.10 version: Image

What I found weird is that I'm finding news regarding the launch of 25.1.83 version for MacOS, the AppStore even have a changelog, that weirdly doesn't show 25.1.10: Image

luciodaou avatar Feb 06 '25 02:02 luciodaou

@JayaswalPrateek @moenodedev @luciodaou Thanks for the info.

Are any of you able to install WhatsApp 25.1.83 directly from the App Store GUI?

Does the same problem occur when trying to upgrade GRIS+, either via mas or via the App Store GUI?

(I'm away from my computer, so can't test now)

rgoldberg avatar Feb 06 '25 03:02 rgoldberg

Yes, removing it and reinstalling it from the App Store installs the latest version and the subsequent mas upgrade will downgrade it from 25.1.83 to 25.1.10

I would like to propose a temporary workaround by adding a --ignore subcommand to specify such packages which will be ignored during mas upgrade. This will ensure other packages can be swiftly upgraded.

JayaswalPrateek avatar Feb 06 '25 07:02 JayaswalPrateek

@JayaswalPrateek @moenodedev @luciodaou Thanks for the info.

Are any of you able to install WhatsApp 25.1.83 directly from the App Store GUI?

Does the same problem occur when trying to upgrade GRIS+, either via mas or via the App Store GUI?

(I'm away from my computer, so can't test now)

I can't. That's exactly what I tried to do using the app store, after removing and reinstall, it installed 25.1.10.

Yes, same thing with GRIS+.

The appstore doesn't offer me an update option for either app.

I'm starting to believe this is related to the app store more than with mas.

luciodaou avatar Feb 06 '25 08:02 luciodaou

@JayaswalPrateek @luciodaou mas upgrade 310633997 upgraded me to 25.1.10. I could not use mas to upgrade to a newer version.

mas info 310633997 & the US App Store showed that 25.1.83 was available, but the App Store only showed "Open" instead of "Update".

I uninstalled WhatsApp 25.1.10 using Finder. I downloaded WhatsApp from the US App Store, but it also installed 25.1.10, not 25.1.83.

@luciodaou Was that your experience, too?

@JayaswalPrateek It sounds like: after uninstalling WhatsApp 25.1.10 (did you use mas, Finder, something else?), you downloaded WhatsApp from the IN App Store, and it installed 25.1.83. If that is correct, how did you verify the version? Did you open WhatsApp, then open the About dialog via the menu --> WhatsApp -> About WhatsApp? If so, I don't know why things behaved differently for you than for me (& possibly for @luciodaou).

rgoldberg avatar Feb 06 '25 18:02 rgoldberg

@JayaswalPrateek @luciodaou mas upgrade 310633997 upgraded me to 25.1.10. I could not use mas to upgrade to a newer version.

mas info 310633997 & the US App Store showed that 25.1.83 was available, but the App Store only showed "Open" instead of "Update".

I uninstalled WhatsApp 25.1.10 using Finder. I downloaded WhatsApp from the US App Store, but it also installed 25.1.10, not 25.1.83.

@luciodaou Was that your experience, too?

Exactly that! I uninstalled Whatsapp through the Launchpad (iPad like screen). And my AppStore is the Brazilian one.

luciodaou avatar Feb 06 '25 19:02 luciodaou

@rgoldberg Few days back, I did try uninstalling 25.1.10 and was able to reinstall it as 25.1.83(as seen in Menu -> WhatsApp -> About WhatsApp) from IN App Store. I tried it again today, and I am no longer able to download 25.1.83 from the IN App Store even though it's marked as the latest release(25.1.10 was downloaded instead). And the 'Open' button is not marked as 'Update' on the IN App Store page for WhatsApp either.

This seems like an App Store quirk where the latest release is bumped up in the metadata/release notes without the download being made available, which causes mas to redownload the previous version(that's most likely already installed) all over again.

My current gripe is that everytime I run mas upgrade regardless of the fact if there are other updates available, WhatsApp is always redownloaded, which causes significant bandwidth wastage as it's a pretty large app. Is there a way for mas to avoid this? Either by having a --ignore flag which won't upgrade certain specified packages, or by detecting that while trying to update 25.1.10 to 25.1.83 its downloading 25.1.10 again so it should simply skip that download instead as its already downloaded. Such events aren't errors per se, and instead can be displayed as a WARNING that the new release isn't available in your region, try again later.

So instead of this:

prateek@Prateeks-MacBook ~> mas upgrade
Upgrading 1 outdated application:
WhatsApp Messenger (25.1.10) -> (25.1.83)
==> Downloaded WhatsApp Messenger (25.1.10)
==> Installing WhatsApp Messenger (25.1.10)
==> Installed WhatsApp Messenger (25.1.10)

we could have something like:

prateek@Prateeks-MacBook ~> mas upgrade
Upgrading 1 outdated application:
WhatsApp Messenger (25.1.10) -> (25.1.83)
WARNING: Skipping it, version 25.1.83 not available in your region

or mas upgrade --ignore "Whatsapp" mas upgrade --ignore 310633997

JayaswalPrateek avatar Feb 07 '25 10:02 JayaswalPrateek

@JayaswalPrateek @moenodedev @luciodaou

I used mas 1.9.0 to upgrade WhatsApp to the recently released 25.2.79 using the US region. Does it work correctly for all of you?

Are any other apps (maybe GRIS+) currently exhibiting the bad behavior?

It's probably a bad idea to skip upgrades, and it might be hard to do so.

I don't know if we can skip an upgrade if the version supplied by Apple's CommerceKit private framework is older than the version reported by Apple's iTunes Search Web API, because we currently get the former only after the installation process has been started.

Moreover, the version specified by iTunes Search is the newest version for any version of macOS, not the newest for your version of macOS, which might be an older version of the app. And if a newer release was removed from the App Store because it contains bugs, then we should probably downgrade if the App Store would downgrade.

I don't think that reinstalling the same version of an app causes any issues, so the only time we might want to skip really doesn't need a skip. Additionally, maybe someone can release a new build of an app using the same version number, in which case we'd definitely want to reinstall. I'd have to investigate, but it probably isn't worth the time to investigate.

We could try to detect the scenario, then output an explanation about it.

This situation might cause a little confusion, but there doesn't seem to be anything wrong in mas' behavior besides not explaining things well to the user.

Whatever is decided, I won't be able to get to this for a while.

rgoldberg avatar Feb 15 '25 01:02 rgoldberg

Just ran Latest.

WhatsApp is now fine. GRIS is still the same, but I uninstalled it.

Now the stuck app is OneDrive:

Image

luciodaou avatar Feb 15 '25 03:02 luciodaou

@luciodaou Does Latest use mas?

rgoldberg avatar Feb 15 '25 10:02 rgoldberg

Not sure, but both show the same behavior...

Image

luciodaou avatar Feb 15 '25 15:02 luciodaou

@luciodaou Can you try deleting OneDrive, then:

  • provide the version of OneDrive listed in the App Store app
  • install OneDrive directly from the App Store app
  • provide the version of OneDrive reported in its own OneDrive > About OneDrive dialog
  • provide the version of OneDrive output by mas list, mas outdated & mas upgrade

rgoldberg avatar Feb 15 '25 16:02 rgoldberg

AppStore doesn't offer Update option, same behavior as previously with WhatsApp.

Image

Image

Image

Image

luciodaou avatar Feb 19 '25 00:02 luciodaou

@luciodaou Did you delete OneDrive at the beginning of the process as instructed? (it was before the bullet points)

rgoldberg avatar Feb 19 '25 04:02 rgoldberg

@luciodaou Did you delete OneDrive at the beginning of the process as instructed? (it was before the bullet points)

Yes, just as I did with WhatsApp earlier...

luciodaou avatar Feb 20 '25 19:02 luciodaou

@luciodaou @JayaswalPrateek @moenodedev If version pinning / ignoring is implemented (#386), it could be used to avoid repeatedly upgrading to the same old version of an app.

The simplest implementation would require a user to manually ignore the version.

An improvement would be to warn to stderr if any upgrade installs a version other than was expected.

A setting could be added that enables either or both of the following:

  • promoting the user if they want to ignore the version in the future.
  • automatically ignoring the version was installed.

That would require mas to support settings, which it currently doesn't yet support.

I could look into aborting upgrading if the version differs from what was expected. If that can be done, there could be a setting to install regardless, automatically abort, or prompt the user.

Is that a good solution?

rgoldberg avatar Apr 09 '25 14:04 rgoldberg

I prefer the second option. It seems easier to implement and to explain to users.

I could look into aborting upgrading if the version differs from what was expected. If that can be done, there could be a setting to install regardless, automatically abort, or prompt the user.

luciodaou avatar Apr 10 '25 02:04 luciodaou

Problem(s) addressed The version number shown within the app is different from the version number listed on the App Store, which causes frequent update prompts.

https://apps.apple.com/us/app/sparrow-weather/id6449440582

6449440582 Sparrow Weather (3.8 -> 21)

Version (in App) : 3.8

Version (In App Store) :21

Accademia avatar Apr 16 '25 04:04 Accademia