XcodesOrg / xcodes

The best command-line tool to install and switch between multiple versions of Xcode.
MIT License
3.68k stars 126 forks source link

proposal/question: improving diagnostics/handling of a cached invalid username #149

Closed jamieQ closed 2 years ago

jamieQ commented 3 years ago

hi! first, thanks for this tool – it's much more pleasant to use than navigating through the dev portal to find the latest Xcode update. after having used xcodes several times in the past, i recently encountered an issue that was a bit difficult to diagnose. the setup:

  1. i had previously installed Xcode via xcodes with Apple ID $email_1
  2. i changed my Apple ID to $email_2
  3. i attempted to install a new version of Xcode via xcodes

on step 3, i repeatedly received authentication errors, re-prompting me for my password (which was unchanged), but was not provided any way to re-enter my username (which was now incorrect). after a bit of digging through this repo, i discovered that the 'default' username gets cached in a configuration file for use in subsequent invocations. once i realized this, it was easy enough to fix, but it did take me a while to figure out what was going on.

so, i was wondering if we could add either some improved feedback, perhaps indicating how to override the cached value (it seemed like env variable, or editing the config file would both work), or introduce behavior that will re-prompt for the username in addition to the password based on some criteria.

admittedly, this is likely a very narrow edge-case, since i don't think Apple IDs change that often. still, i'd be willing to try and implement an improvement for this particular snag i hit, time permitting. so, my question is what approach should i pursue to improve this?

thii commented 3 years ago

There's this in the README:

If you need to use a different Apple ID than the one that's remembered, set the XCODES_USERNAME environment variable.

MattKiazyk commented 3 years ago

Hi @jamieQ - thanks for the words.

A recent PR #136 that has been merged to main adds a signout command that will handle the situation you're into. It will remove all the caches it has as well as any keychain items.

This has not been released yet unfortunately. I'll try to get to that soon.

jamieQ commented 3 years ago

thanks for the prompt response! looks like the proposed addition in #136 would have made my experience easier. thanks!

shepting commented 3 years ago

@MattKiazyk Where are those caches located? I was investigating how the credentials could be distributed across CI machines and only saw the keychain item.

MattKiazyk commented 3 years ago

Hi @shepting - any cache that Xcodes would save would be in ~/Library/Application Support/com.robotsandpencils.xcodes

There may be some caching done by the the Mac that we can't control.

MattKiazyk commented 2 years ago

0.19.0 was released yesterday, and the signout command should help in this situation to clear things out.