mas-cli / mas

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

`upgrade` hangs via ssh #128

Open mmaietta opened 6 years ago

mmaietta commented 6 years ago

I've been unable to upgrade Xcode on any of my Jenkins slave nodes via ssh. I have tried both tmux into multiple machines and ssh-ing into only one to run the command. Both have failed (or rather, just stall) with and without reattach-to-user-namespace being used.

QAMini:~ jenkins$ mas list
409183694 Keynote (7.2)
497799835 Xcode (9.0)
409201541 Pages (6.2)
409203825 Numbers (4.2)

QAMini:~ jenkins$ mas outdated
409203825 Numbers (4.2 -> 4.3.1)
409183694 Keynote (7.2 -> 7.3.1)
409201541 Pages (6.2 -> 6.3.1)
497799835 Xcode (9.0 -> 9.2)

QAMini:~ jenkins$ sudo mas upgrade 497799835 
Password:
Warning: Nothing found to upgrade

QAMini:~ jenkins$ mas upgrade 497799835 
Upgrading 1 outdated application:
Xcode (9.2)

/// No progress after a few hours.

QAMini:~ jenkins$ reattach-to-user-namespace mas upgrade 497799835 
Upgrading 1 outdated application:
Xcode (9.2)

/// No progress after a few hours.

It hangs and never completes. I've left it running for hours without success.

Note: If I screen share into the mac mini and run it via terminal, it works just fine, however, that approach won't scale and isn't feasible for the number of macs nodes we are using with Jenkins.

I've removed all other installations of Xcode on the system and have also removed the "Install OSX High Sierra.app" in hopes that it would change any behavior when via ssh. Again, regardless of the two above environment characteristics (Xcode.app + Xcode8.3.app + Install OSX High Sierra.app), running mas upgrade still works via screenshare.

Can you please advise? Is there a way to enable verbose output to provide any additional details necessary?

Possibly related, using mas via a Brewfile hangs indefinitely as well for me.

brew 'mas'
mas 'Xcode', id: 497799835
phatblat commented 6 years ago

Thanks for the report @mmaietta. I'd like to see if I can replicate this, but I don't usually install Xcode from the MAS, prefer to download .dmg files manually or use xcode-install. I'll need to get 9.2 installed on a box and then test it when 9.3 rolls out.

Perhaps a progress bar for long downloads would help indicate whether mas is actually doing anything. That or perhaps some system logging. Basically, this won't be a quick fix but please update this issue if you come across any info while I look into it.

mmaietta commented 6 years ago

Oh, I wasn't aware of that gem! It's worth noting, though, that all App Store apps fail to install via mas when ran through an ssh session. A progress bar could certainly help, but I think the best way to provide more insight would be to enable system logging with a --verbose flag or something.

mima-mima commented 6 years ago

I can verify this behavior with mas 1.3.1 that's the latest version I see in brew, going to try to get updated to 1.4.1 here, but I'm seeing no activity when SSH'd to a machine, but do have an upgrade process from Terminal when in an ARD remote session.

signout, signin, list* have no issues from SSH.

*I've always had to use AppleScript to sign into the console and spawn Mac App Store to get the list to update.

mima-mima commented 6 years ago

Good news for me: calling mas through ARD commands behaves as though running locally, so while I can't test my scripts via SSH they will work when pushed through ARD.

mmaietta commented 6 years ago

Hmmm interesting, I never thought to try it via apple script. I attempted writing a bash script to do so, but it wouldn't execute updates either - figured due to still being run via ssh?

ARD always worked fine for me, but then I'm back to square one in terms of updating all my jenkin slave nodes one by one.

jsvh commented 6 years ago

I am having this same problem. It occurs if I use ssh or ARD. The problem is resolved if the user is actively logged in on the remote computer (not what I want). Otherwise if trying to update while the remote computer is on the login screen then mas says I have no installed apps. I update chrome and iWork apps. I can go back and forth with the list being displayed or not.

Garulf commented 5 years ago

Seeing the same issue. The installation silently hangs.

I’ve attempted using screen or Tmux with no results.

cdalvaro commented 5 years ago

Maybe this is related with issue #89

mike-pt commented 5 years ago

I believe the issue is how the download progress is handled --> https://github.com/mas-cli/mas/blob/45f08747cf5b1b70216b7376ecb53742fb19cc09/MasKit/AppStore/PurchaseDownloadObserver.swift but I don't know swift to be able to help.

Unfortunately this breaks automation tools like ansible because twe can't run a task like mas install or mas upgrade in a non interactive shell :(

cdalvaro commented 5 years ago

I believe the issue is how the download progress is handled --> https://github.com/mas-cli/mas/blob/45f08747cf5b1b70216b7376ecb53742fb19cc09/MasKit/AppStore/PurchaseDownloadObserver.swift but I don't know swift to be able to help.

Unfortunately this breaks automation tools like ansible because twe can't run a task like mas install or mas upgrade in a non interactive shell :(

I am on the same situation. I was building a SaltStack module for installing apps from the Mac App Store using this great utility but I had to stop until this issue is solved.

lvxianchao commented 5 years ago

Sometimes, mas doesn't work. @phatblat

image

phatblat commented 5 years ago

@lvxianchao your issue seems more like #111 since you're using a full window/GUI session. The other comments here are talking about tmux or ssh sessions.

phatblat commented 5 years ago

One thing to keep in mind, if mas outdated is showing updates pending, then the same user should be able to mas upgrade them. However, sudo mas upgrade is running as a different user which is probably not signed into the app store. Unfortunately, signin in via the CLI isn't possible right now (see #164). Otherwise, I'd suggest a command pipe that does signin 😔.

The root issue here is that the APIs that mas is tapped into were never intended to be used without a GUI as they are the (unofficial and unsupported) Apple APIs behind the App Store.app. However, it is the goal of this tool to provide this sort of functionality, but each case that tries to interact with a GUI session is going to have to be found and somehow dealt with to prevent these hangs.

So, sorry for the lack of progress. This is a valid issue, but challenging to resolve.