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

Forward legible errors #143

Closed ffittschen closed 3 years ago

ffittschen commented 3 years ago

I'm currently trying to uninstall Xcode 12.5 Beta 3 using xcodes, but it fails with the following error:

$ xcodes uninstall 12.5 Beta 3
The operation couldn’t be completed. (ExitCode(rawValue: 1))

Upon investigating the cause, I discovered that the error is not correctly forwarded, which is why I can't see the real error message. This PR fixes that and forwards the catched errors.

MattKiazyk commented 3 years ago

Thanks for the PR @ffittschen - I'm curious what the result was on your machine with that change?

ffittschen commented 3 years ago

I didn't see the result, but I figured out the issue:

We are using xcodes within ansible playbooks to manage our Xcode installations on the CI machines. As the xcodes install command interactively asks for a password, we run the command using become: true to avoid this. As it turns out, subsequently calling xcodes uninstall without become: true results in the error I posted above. But when I add become: true to the uninstall call, the Xcode.app is actually moved to /private/var/root/.Trash/ instead of ~/.Trash/. As a workaround I added an "Empty trash" task after the uninstall task, which is not great 😄 Ideally, the xcodes uninstall command would have a --force option to avoid the empty trash step, but that's another topic and I'll open an issue for that to discuss it 🙂

Do you happen to have any suggestions on how to run xcodes install / uninstall without sudo or become: true in a non-interactive way?

MattKiazyk commented 3 years ago

@ffittschen I'm going to merge this in and release it. If you want - can you open up an issue to talk about the other issue you've brought up.

Thanks for the PR - sorry it took so long to get through