Change:
def _download(path, url, probably_big, verbose, exception, help_on_error=None): <ins> # Try to use curl (potentially available on win32 #    https://devblogs.microsoft.com/commandline/tar-and-curl-come-to-windows/) # If an error occurs: #  - If we are on win32 fallback to powershell #  - Otherwise raise the error if appropriate </ins> if probably_big or verbose: print("downloading {}".format(url)) <del> # see https://serverfault.com/questions/301128/how-to-download if sys.platform == 'win32': run(["PowerShell.exe", "/nologo", "-Command", "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;", "(New-Object System.Net.WebClient).DownloadFile('{}', '{}')".format(url, path)], verbose=verbose, exception=exception) else: </del> <ins> platform_is_win32 = sys.platform == 'win32' try: </ins> if probably_big or verbose: option = "-#" else: option = "-s" <del> require(["curl", "--version"]) </del> <ins> # If curl is not present on Win32, we shoud not sys.exit #   but raise `CalledProcessError` or `OSError` instead require(["curl", "--version"], exception=platform_is_win32) </ins> run(["curl", option, "-L", # Follow redirect. "-y", "30", "-Y", "10",    # timeout if speed is < 10 bytes/sec for > 30 seconds "--connect-timeout", "30",  # timeout if cannot connect within 30 seconds "--retry", "3", "-Sf", "-o", path, url], verbose=verbose, <del> exception=exception, </del> <ins> exception=True, # Will raise RuntimeError on failure </ins> help_on_error=help_on_error) <ins> except (subprocess.CalledProcessError, OSError, RuntimeError): # see http://serverfault.com/questions/301128/how-to-download if platform_is_win32: run(["PowerShell.exe", "/nologo", "-Command", "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;", "(New-Object System.Net.WebClient).DownloadFile('{}', '{}')".format(url, path)], verbose=verbose, exception=exception) # Check if the RuntimeError raised by run(curl) should be silenced elif verbose or exception: raise </ins> def verify(path, expected, verbose):

Discussion:
I just cloned this rust repo and attemped to build it by calling It initialized submodules, started downloading and failed repeatedly: Waiting longer causes messages above to repeat. It's not connection issue, because it always fails after ~30 seconds of downloading (Messages above repeat in ~2 minutes). I also tried changing to here: What caused download to succeed in a few (1-2) minutes. So I assume it's to blame. version:
I got x.py to test libcore once, but after I updated my local clone of rust, I started getting this repeatedly:
I am nuking my entire rust clone in case changes to the bootstrap are incompatible to previous artifacts produced by previous versions. Why does x.py need to download submodules like and if I am only trying to test ? edit: apparently, this is expected
Nope, I am still getting the DownloadFile exception after refreshing everything, including updating MSYS2 to get curl to 7.65.1, trying the MSYS2 that comes along with git, and messing with
your issue is different and there is no involved (it downloads file through PowerShell). You can see this MSYS2 patch how to make it use instead:
Thank you, it works now
original issue (from comment 0) is not resolved. reported another issue that isn't solved either, there is only workaround available.
We should probably fallback to trying curl if the powershell invocation fails. Reopening. I think a PR would work best here.
For some reason, the powershell download is working again on both my MSYS2 install and from git bash. We still want that fallback though. I couldn't PR a fix though, because I don't know how the exception handling is working in that Python script.
Actually, since I should learn Python anyway, should I PR a fix? Is it as simple as detecting an exception occurred and refactoring the if-else statement in a way that it would also run ?
That's what I would suggest -- we can make it pretty simple and if anything goes wrong with the powershell call then fallback to curl
It might also make sense to try curl before using powershell, as suggested by in label: +E-easy