Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloading python from behind corporate proxy fails to download in uv but works with wget and rye #9747

Closed
aglove2189 opened this issue Dec 9, 2024 · 7 comments · Fixed by #9753
Assignees
Labels
bug Something isn't working network Network connectivity e.g. proxies, DNS, and SSL

Comments

@aglove2189
Copy link

aglove2189 commented Dec 9, 2024

uv

RUST_LOG=uv=trace uv --native-tls python install 3.11 --no-cache
DEBUG uv 0.5.4
TRACE ld path: /lib64/ld-linux-x86-64.so.2
TRACE stdout output from `ld`: ""
TRACE stderr output from `ld`: "/lib64/ld-linux-x86-64.so.2: missing program name\nTry '/lib64/ld-linux-x86-64.so.2 --help' for more information.\n"
TRACE Tried to find musl version by running `"/lib64/ld-linux-x86-64.so.2"`, but failed: Could not find musl version in output of: `/lib64/ld-linux-x86-64.so.2`
TRACE Tried to find libc version from possible symlink at "/lib64/ld-linux-x86-64.so.2", but failed: Failed to find glibc version in the filename of linker: `/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2`
TRACE stdout output from `ldd --version`: "ld.so (Debian GLIBC 2.36-9+deb12u8) stable release version 2.36.\nCopyright (C) 2022 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions.\nThere is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\nPARTICULAR PURPOSE.\n"
TRACE Found manylinux 2.36 in stdout of `ldd --version`
TRACE Checking lock for `/home/akglover/.local/share/uv/python` at `/home/akglover/.local/share/uv/python/.lock`
DEBUG Acquired lock for `/home/akglover/.local/share/uv/python`
TRACE Found existing installation cpython-3.12.6-linux-x86_64-gnu
TRACE Found existing installation cpython-3.9.20-linux-x86_64-gnu
DEBUG No installation found for request `Python 3.11`
DEBUG Found download `cpython-3.11.10-linux-x86_64-gnu` for request `Python 3.11`
DEBUG Using request timeout of 30s
TRACE Handling request for https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
TRACE Request for https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz is unauthenticated, checking cache
TRACE No credentials in cache for URL https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
TRACE Attempting unauthenticated request for https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
cpython-3.11.10-linux-x86_64-gnu ------------------------------     0 B/20.22 MiB                                                       DEBUG Downloading https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz to temporary location: /home/akglover/.local/share/uv/python/.cache/.tmpWo6eia
DEBUG Extracting cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
cpython-3.11.10-linux-x86_64-gnu ------------------------------ 12.20 MiB/20.22 MiB                                                     TRACE Attempting to retry error: ExtractError("cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz", Io(Custom { kind: UnexpectedEof, error: TarError { desc: "failed to unpack `/home/akglover/.local/share/uv/python/.cache/.tmpWo6eia/python/lib/python3.11/ensurepip/_bundled/pip-24.0-py3-none-any.whl`", io: Custom { kind: UnexpectedEof, error: TarError { desc: "failed to unpack `python/lib/python3.11/ensurepip/_bundled/pip-24.0-py3-none-any.whl` into `/home/akglover/.local/share/uv/python/.cache/.tmpWo6eia/python/lib/python3.11/ensurepip/_bundled/pip-24.0-py3-none-any.whl`", io: Custom { kind: UnexpectedEof, error: "unexpected end of file" } } } } }))
TRACE Cannot retry error: not a reqwest error
error: Failed to install cpython-3.11.10-linux-x86_64-gnu
  Caused by: Failed to extract archive: cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
  Caused by: failed to unpack `/home/akglover/.local/share/uv/python/.cache/.tmpWo6eia/python/lib/python3.11/ensurepip/_bundled/pip-24.0-py3-none-any.whl`
  Caused by: failed to unpack `python/lib/python3.11/ensurepip/_bundled/pip-24.0-py3-none-any.whl` into `/home/akglover/.local/share/uv/python/.cache/.tmpWo6eia/python/lib/python3.11/ensurepip/_bundled/pip-24.0-py3-none-any.whl`
  Caused by: unexpected end of file
DEBUG Released lock at `/home/akglover/.local/share/uv/python/.lock`

rye

rye toolchain fetch cpython@3.11 -v
target dir: /home/akglover/.rye/py/cpython@3.11.10
download url: https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-pgo%2Blto-full.tar.zst
Downloading cpython@3.11.10
Checking checksum
Unpacking
Downloaded cpython@3.11.10

wget

wget https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
--2024-12-09 13:28:29--  https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
Resolving github.com (github.com)... 140.82.113.4
Connecting to github.com (github.com)|140.82.113.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/162334160/bc9e9129-99c7-4349-b9d9-0d423765697a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20241209%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241209T192638Z&X-Amz-Expires=300&X-Amz-Signature=d217e3df5b2776df29cc2c970250f40489934119c2fc641228a91937cd953d88&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dcpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz&response-content-type=application%2Foctet-stream [following]
--2024-12-09 13:28:29--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/162334160/bc9e9129-99c7-4349-b9d9-0d423765697a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20241209%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241209T192638Z&X-Amz-Expires=300&X-Amz-Signature=d217e3df5b2776df29cc2c970250f40489934119c2fc641228a91937cd953d88&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dcpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.110.133, 185.199.109.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21205300 (20M) [application/octet-stream]
Saving to: ‘cpython-3.11.10+20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz.1’

cpython-3.11.10+20241016-x86_64-u  60%[====================================>                         ]  12.28M  1.52MB/s    in 8.1s    

2024-12-09 13:28:37 (1.52 MB/s) - Read error at byte 12876058/21205300 (Error in the pull function.). Retrying.

--2024-12-09 13:28:38--  (try: 2)  https://objects.githubusercontent.com/github-production-release-asset-2e65be/162334160/bc9e9129-99c7-4349-b9d9-0d423765697a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20241209%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241209T192638Z&X-Amz-Expires=300&X-Amz-Signature=d217e3df5b2776df29cc2c970250f40489934119c2fc641228a91937cd953d88&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dcpython-3.11.10%2B20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz&response-content-type=application%2Foctet-stream
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 21205300 (20M), 8329242 (7.9M) remaining [application/octet-stream]
Saving to: ‘cpython-3.11.10+20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz.1’

cpython-3.11.10+20241016-x86_64-u 100%[+++++++++++++++++++++++++++++++++++++========================>]  20.22M  19.1MB/s    in 0.4s    

2024-12-09 13:28:39 (19.1 MB/s) - ‘cpython-3.11.10+20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz.1’ saved [21205300/21205300]
@aglove2189
Copy link
Author

Just a guess but it seems like the read gets corrupted, wget and/or rye retries / resumes but uv doesn't?

@charliermarsh
Copy link
Member

Are you seeing this consistently? Like every time?

@charliermarsh
Copy link
Member

I'm a little surprised we aren't retrying there... we do have retries setup, but I guess something is being lost because it's technically an extraction error? I'd have to find a way to reproduce it.

@charliermarsh charliermarsh added the network Network connectivity e.g. proxies, DNS, and SSL label Dec 9, 2024
@aglove2189
Copy link
Author

Yes it's happening consistently across multiple machines and OSs

@charliermarsh
Copy link
Member

I'll look into it, though it seems not-great that your proxy is consistently failing :)

@aglove2189
Copy link
Author

Oh trust me I very much agree :). I'm working internally on diagnosing the root proxy issue so no worries if you want to close this issue.

@charliermarsh
Copy link
Member

Na all good, we should be retrying here! I'm just worried that I'll have trouble emulating the exact error.

@charliermarsh charliermarsh self-assigned this Dec 9, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Dec 9, 2024
charliermarsh added a commit that referenced this issue Dec 10, 2024
## Summary

So the error here is:

```rust
ExtractError("cpython-3.11.11%2B20241206-aarch64-apple-darwin-install_only_stripped.tar.gz", Io(Custom { kind: UnexpectedEof, error: TarError { desc: "failed to unpack `/Users/crmarsh/.local/share/uv/python/.cache/.tmpkqFzqE/python/lib/libpython3.11.dylib`", io: Custom { kind: UnexpectedEof, error: TarError { desc: "failed to unpack `python/lib/libpython3.11.dylib` into `/Users/crmarsh/.local/share/uv/python/.cache/.tmpkqFzqE/python/lib/libpython3.11.dylib`", io: Custom { kind: UnexpectedEof, error: "unexpected end of file" } } } } }))
```

This isn't a Reqwest error, so we miss it in
`is_extended_transient_error`.

We could add `TarError` or `ExtractError` here, but... should we? This
PR just extends it to any error that has an IO source. I don't see much
of a downside.

Closes #9747.

## Test Plan

First, ran: `uv run ./scripts/create-python-mirror.py --name cpython
--arch aarch64 --os darwin`.

Then, dropped this into `./scripts/mirror/server.py`:

```python
import os
import random
from http.server import SimpleHTTPRequestHandler, HTTPServer


class GlitchyStaticServer(SimpleHTTPRequestHandler):
    def do_GET(self):
        """Handle GET request."""
        file_path = self.translate_path(self.path)
        
        if not os.path.exists(file_path):
            self.send_error(404, "File not found")
            return
        
        try:
            with open(file_path, 'rb') as f:
                file_content = f.read()

            # Introduce an "unexpected end of file" glitch randomly
            if random.random() < 0.75:  # 75% chance of glitch
                glitch_point = random.randint(1, len(file_content) - 1)
                file_content = file_content[:glitch_point]

            self.send_response(200)
            self.send_header("Content-type", self.guess_type(file_path))
            self.send_header("Content-Length", len(file_content))
            self.end_headers()
            self.wfile.write(file_content)
        
        except Exception as e:
            self.send_error(500, f"Internal Server Error: {e}")
        

def run(server_class=HTTPServer, handler_class=GlitchyStaticServer, port=8080):
    """Run the server."""
    server_address = ('', port)
    httpd = server_class(server_address, handler_class)
    print(f"Serving on port {port} with glitchy behavior")
    httpd.serve_forever()


if __name__ == "__main__":
    run()
```

Then ran `python server.py` from that directory.

From there, ran `UV_PYTHON_INSTALL_MIRROR="http://localhost:8080" cargo
run python install 3.11 --reinstall --verbose` to reliably test retries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working network Network connectivity e.g. proxies, DNS, and SSL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants