xcpretty / xcode-install

🔽 Install and update your Xcodes
https://fastlane.tools
MIT License
2.58k stars 237 forks source link

permission denied #456

Open sdarwin opened 2 years ago

sdarwin commented 2 years ago

When installing multiple xcode versions, using a command such as:

xcversion install 11.3 --no-switch

There were occasionally errors such as this:

xip: error: The archive “Xcode_11.3.xip” failed to be moved to the final destination due to the error: The operation couldn’t be completed. Permission denied.
No `Xcode.app(or Xcode-beta.app)` found in XIP. Please remove /Users/administrator/Library/Caches/XcodeInstall/Xcode_11.3.xip if you suspect a corrupted download or run `xcversion update` to see if the version you tried to install has been pulled by Apple. If none of this is true, please open a new GH issue. 

However,

The question is about those error messages. The above message included:

  1. Permission Denied.

Permission to do what? Permission on which file or directory? Could the message be more verbose?

  1. No Xcode.app(or Xcode-beta.app) found in XIP.

Did not seem to be true, because I could manually unxip it. Also - if the problem really was " No Xcode.app(or Xcode-beta.app) found in XIP. " then why did it also say "permission denied"?

sdarwin commented 2 years ago

If this is an edge-case that nobody has ever encountered, the issue can probably be closed. Nevertheless, here are some ideas to mitigate it. Because the install process can be slow, any quick steps to precheck a success or failure are preferable to waiting many minutes to discover there is a problem.

  1. Add a preflight check to "xcversion install" which occurs before downloading xcode or taking any actions. In the pre-check phase, make sure the user can write to the final destination folder. Write a very small file and then remove it. If the step fails, then clearly indicate which directory is lacking permissions.

  2. Download the xip file. After the download, but before continuing further, verify the shasum, https://github.com/notpeter/apple-installer-checksums/blob/master/xcode.md . Display to the user that the download and checksum were successful. Unless, this is already being done, then nevermind :-)

renfrenkel commented 2 years ago

This is happening to me today too. It's consistently failing every time for me, but the manual unxip works. I can't debug at all since running the command manually works and no useful information is being output by the xcversion command.