xcpretty / xcode-install

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

Simulator install - curl: (18) transfer closed #210

Closed wrutkowski closed 7 years ago

wrutkowski commented 7 years ago

Hi,

I'm experiencing the same error for a long time now and it can happen a few times in a row as in the below log.

This is the command I'm running: xcversion simulators --install="tvOS 10.1"

And this is the log:

$ xcversion simulators --install="tvOS 10.1"
Installing tvOS 10.1 Simulator for Xcode 8.3.0...
####                                                                       5.9%
curl: (18) transfer closed with 1081635138 bytes remaining to read
Mounting DMG
hdiutil: mount failed - no mountable file systems
[!] Failed to invoke hdiutil.
$ xcversion cleanup; xcversion simulators --install="tvOS 10.1"
Installing tvOS 10.1 Simulator for Xcode 8.3.0...
###                                                                        4.5%
curl: (18) transfer closed with 1097622531 bytes remaining to read
Mounting DMG
hdiutil: mount failed - image not recognized
[!] Failed to invoke hdiutil.
$ xcversion cleanup; xcversion simulators --install="tvOS 10.1"
Installing tvOS 10.1 Simulator for Xcode 8.3.0...
##                                                                         3.0%
curl: (18) transfer closed with 1115300867 bytes remaining to read
Mounting DMG
hdiutil: mount failed - image not recognized
[!] Failed to invoke hdiutil.
$ xcversion cleanup; xcversion simulators --install="tvOS 10.1"
Installing tvOS 10.1 Simulator for Xcode 8.3.0...
####                                                                       5.8%
curl: (18) transfer closed with 1082962242 bytes remaining to read
Mounting DMG
hdiutil: mount failed - no mountable file systems
[!] Failed to invoke hdiutil.

Thanks

timsutton commented 7 years ago

I'm not experiencing the "transfer closed" issue, but I do notice that if I Ctrl-C the process and run it again, it assumes an existing download is complete and attempts to mount the dmg.

wrutkowski commented 7 years ago

When I restart it's not continuing to download, just try to mount corrupted file and exit with error. I had to retry and it finally worked, but it's not stable for some reason.

wrutkowski commented 7 years ago

I think the issue is with my network connection. Do you think it's possible to make the downloading script more resistant for connection drops and / or automatic retry?

timsutton commented 7 years ago

XcodeInstall uses some curl flags to automatically finish any incomplete downloads for the Xcode dmgs/xips, so potentially this could be done for the simulator downloads as well.

marcomorain commented 7 years ago

We are getting the same issue at CircleCI:

Installing iOS 10.0
Installing iOS 10.0 Simulator for Xcode 8.3.3...
<curl progressbar>
curl: (18) transfer closed with 140524867 bytes remaining to read
Mounting DMG
hdiutil: mount failed - image not recognized
[!] Failed to invoke hdiutil.
pronebird commented 7 years ago

Same issue here. xcversion keeps mounting corrupt DMG. No recovery from network error whatsoever.

timsutton commented 7 years ago

This is probably a fairly easy fix, to test copying in the same option curl uses for resuming a partial download, if anyone wants to try.

timsutton commented 7 years ago

(and now that I look, I completely missed that @marcomorain has already done work towards that :)

timsutton commented 7 years ago

219 will help for network issues, but if there's an unfinished dmg downloaded we'll still blindly try and mount it. Doing this would at least help ensure we do a full check for a complete download every time:

diff --git a/lib/xcode/install.rb b/lib/xcode/install.rb
index 2a97256..65aec46 100644
--- a/lib/xcode/install.rb
+++ b/lib/xcode/install.rb
@@ -385,7 +385,7 @@ HELP
     end

     def install
-      download unless dmg_path.exist?
+      download
       prepare_package unless pkg_path.exist?
       puts "Please authenticate to install #{name}..."
       `sudo installer -pkg #{pkg_path} -target /`
wrutkowski commented 7 years ago

Thanks @marcomorain 👍