mas-cli / mas

:package: Mac App Store command line interface
MIT License
10.82k stars 272 forks source link

Manually specify region #444

Open Saucken1945 opened 2 years ago

Saucken1945 commented 2 years ago

Your Environment

mas Install Method

Describe the Bug

The region in mas formula (China Mainland) is different from that in Mac App Store (the USA). unable to switch from China Mainland to the USA App Store hence cannot install any application that haven't click 'get' before

To Reproduce

search using: mas search [cask]

Expected Behavior

get results from the USA App Store

Actual Behavior

get results from Chinese App Store

Screenshots, Terminal Output

got results from Chinese App Store

Screenshot 2021-12-28 at 13 35 08

cannot install due to the wrong region

Screenshot 2021-12-28 at 13 36 45

after clicked ok it says "Error: No downloads began"

Screenshot 2021-12-28 at 13 37 43

Additional Context

It gets wrong since yesterday, everything is normal before that.

I haven't switch to a Chinese App Store account before.

I've tried to restart, reinstall mas then restart then reinstall homebrew then restart.

All of those do not work.

Need help, thanks!

chris-araman commented 2 years ago

This is fallout from #442 and #443.

As of 1.8.6, mas now queries the App Store based on the user's region set in macOS. Users that want to manage apps from other regions don't yet have a way to pass that region on the command line. As a workaround, @Saucken1945, you should be able to temporarily select the region of the apps you want to maintain in System Preferences, Language & Region, General, Region.

Moving forward, I propose we add an optional command line flag --region [region-code] where region-code is a one of Apple's supported two-letter region codes (similar to ISO 3166-1 alpha-2). We would make an allowance that the code will be handled in a case-insensitive manner. If --region is not provided, we will continue to default to the user's selected region in System Preferences.

For example:

mas --region US ...
mas --region us ...
mas --region DE ...
mas --region CN ...

(The term "country" is imprecise, because not all recognized regions are countries, but the iTunes Search API still uses the token country as a query parameter.)

@phatblat, does that sound reasonable to you?