asdf-elixir
asdf-elixir copied to clipboard
Fix error 'HTTP server doesn't seem to support byte ranges.'
I get this error under Ubuntu 20.04:
$ asdf install elixir ref:v1.12.2
==> Checking whether specified Elixir reference exists...
==> Downloading v1.12.2 to /home/username/.asdf/downloads/elixir/ref-v1.12.2/elixir-ref-v1.12.2-src.tar.gz
\*\* Resuming transfer from byte position 14
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 127 100 127 0 0 2396 0 --:--:-- --:--:-- --:--:-- 2396
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
==> Making the release
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
The culprit seems to be the second curl commands -C - bit. It's not clear to me why this should be there, because the curl command works fine without it. It would be a good idea to check it on MacOS first, which I can't do.
Also, i've added the -L flag to the does-the-release-exist curl command, so that it follows redirects and checks the existence of the actual file.
Thanks for the PR!
Use "-C -" to tell curl to automatically find out where/how to resume the transfer. It then uses the given output/input files to figure that out.
Given that we may (based on these lines https://github.com/asdf-vm/asdf-elixir/pull/105/files#diff-f9746898bdf5ee311b5c55bc0b6d8c64901f52940c591089b3bfbda5f5b26c8aL8-L15) dynamically generate a temp directory, this -C - option might not work. However in your case it seems like curl tries to get it to work, based on your output:
\*\* Resuming transfer from byte position 14
However it's not clear to me why your last download terminated after only 14 bytes. This may be an indicator of an issue somewhere. I need to figure out if removing -C - is ok or if it will break things for some people. Your other changes look good.
Were you able get around the issue you encountered without making these changes? Did you try deleting any temp files from previous installation attempts?
Right in front of me:
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
If this is true then it explains everything. Let me test this.
The -C - flag seems to work for me when I try it locally:
$ curl -C - https://github.com/elixir-lang/elixir/archive/v1.12.2.tar.gz --output v1.12.2.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 127 100 127 0 0 682 0 --:--:-- --:--:-- --:--:-- 682
100 2402k 0 2402k 0 0 2774k 0 --:--:-- --:--:-- --:--:-- 2774k
$ curl -C - https://github.com/elixir-lang/elixir/archive/v1.12.2.tar.gz --output v1.12.2.tar.gz
** Resuming transfer from byte position 2460047
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 127 100 127 0 0 693 0 --:--:-- --:--:-- --:--:-- 693
0 2402k 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
Yes it works locally for me as well. It's very strange that it tries to "resume" a download. This issue occurred a few times earlier but then I couldn't reproduce it. I only install new elixir versions as they are released, it's not like I do asdf install ref:v1.12.2, then kill the process, and then try to install it again, so it would be weird if temp files were already present for the 1.12.2 release.
Does it work well for you without -C - in the curl commands?
Hmm... i tried it on my other machine (also Ubuntu 20.04) and it seems that a temp file does cause the issue:
$ asdf install elixir ref:v1.12.2
==> Checking whether specified Elixir reference exists...
==> Downloading v1.12.2 to /home/username/.asdf/downloads/elixir/ref-v1.12.2/elixir-ref-v1.12.2-src.tar.gz
** Resuming transfer from byte position 14
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 127 100 127 0 0 1840 0 --:--:-- --:--:-- --:--:-- 1814
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
==> Making the release
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
# a temp file seems to exist? The timestamp is June 14th
$ ls -l ~/.asdf/downloads/elixir/ref-v1.12.2/
total 1
-rw-rw-r-- 1 username username 14 jun 21 15:51 elixir-ref-v1.12.2-src.tar.gz
# after removing it, the install works
$ rm ~/.asdf/downloads/elixir/ref-v1.12.2/elixir-ref-v1.12.2-src.tar.gz
$ asdf install elixir ref:v1.12.2
==> Checking whether specified Elixir reference exists...
==> Downloading v1.12.2 to /home/username/.asdf/downloads/elixir/ref-v1.12.2/elixir-ref-v1.12.2-src.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 127 100 127 0 0 1476 0 --:--:-- --:--:-- --:--:-- 1494
100 2402k 0 2402k 0 0 3369k 0 --:--:-- --:--:-- --:--:-- 11.6M
==> Making the release
# builds successfully
So I guess that I've tried asdf install ref:v1.12.2 before on June 14th, as a lazy way of checking if elixir 1.12.2 was released yet. Then the temp file got created, and now it is in the way of a successful install now that elixir 1.12.2 does in fact exist.
Apparently, removing the -C - allows curl to overwrite the tempfile, which is nice, but I guess the cleaner solution would be to remove the temp file first. What would be your preference? Then I'll update the PR
When I try to download a non-existant Elixir version (at this moment 1.12.3 doesn't exist), I see destination directory for the download is empty, no temp file exists. If the request fails due to 404 or 403, we print a message for the user and don't try to download the version at all. So you got past that somehow something else is wrong. For example, I get this output as expected:
https://github.com/elixir-lang/elixir/archive/1.12.3.tar.gz
==> Checking whether specified Elixir reference exists...
==> Elixir reference not found.
GitHub returned a 404 for the following URL:
https://github.com/elixir-lang/elixir/archive/1.12.3.tar.gz
You can view a list of all Elixir releases by running 'asdf list-all elixir'
or by visiting https://github.com/elixir-lang/elixir/releases
Note: If you want to specify a git reference by which to install
Elixir, it must be a valid git tag or branch (generally of the form v1.2.1).
And with my configuration the temp download would get written to $HOME/.asdf/downloads/elixir/ref-1.12.3, and asdf creates this directory but with the invalid version it is left empty:
total 0
drwxr-xr-x 2 user staff 64 Sep 3 17:46 .
drwxr-xr-x 8 user staff 256 Sep 3 17:46 ..
Sorry for the late reply here! I saw your comments at a time when I was busy and forgot about this thread.
@juulSme circling back here. There are two changes in your PR:
- Add
-Lto follow redirects. I have no objection to this if you have evidence it's necessary - Remove
-C -so curl does not try to resume incomplete downloads. I haven't had any issues with resuming downloads, they always work for me, so I'm not sure we need to remove this.
Closing this PR due to lack of a response. I am not certain we need all these changes. We can re-evaluate this in the future if someone encounters a problem.