Skip to content

Cannot compile uv-client as cargo dependency #15471

@felixmulder

Description

@felixmulder

Summary

We're running a project that needs to invoke uv programmatically (we don't expect any API stability, don't worry). However, I'm a bit confused as to why I can't build the project at all as a dependency.

Minimal repro, cargo init uv-repro && cd uv-repro with:

# Cargo.toml
[package]
name = "uv-repro"
version = "0.1.0"
edition = "2024"

[dependencies]
uv-client = { git = "https://github.com/astral-sh/uv", rev = "088c908cda450d63db838ab41620d25c34a8d1fa" }
$ cargo build

Output:

   Compiling uv-client v0.0.1 (https://github.com/astral-sh/uv#f1647838)
error[E0277]: the trait bound `reqwest_middleware::client::ClientWithMiddleware: From<RedirectClientWithMiddleware>` is not satisfied
   --> /Users/x/.cargo/git/checkouts/uv-c9e40703e19509a8/f164783/crates/uv-client/src/registry_client.rs:937:25
    |
936 |                     let mut reader = AsyncHttpRangeReader::from_head_response(
    |                                      ---------------------------------------- required by a bound introduced by this call
937 |                         self.uncached_client(url).clone(),
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<RedirectClientWithMiddleware>` is not implemented for `reqwest_middleware::client::ClientWithMiddleware`
    |
    = help: the trait `From<RedirectClientWithMiddleware>` is not implemented for `reqwest_middleware::client::ClientWithMiddleware`
            but trait `From<reqwest::Client>` is implemented for it
    = help: for that trait implementation, expected `reqwest::Client`, found `RedirectClientWithMiddleware`
    = note: required for `RedirectClientWithMiddleware` to implement `Into<reqwest_middleware::client::ClientWithMiddleware>`
note: required by a bound in `AsyncHttpRangeReader::from_head_response`
   --> /Users/x/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async_http_range_reader-0.9.1/src/lib.rs:304:22
    |
303 |     pub async fn from_head_response(
    |                  ------------------ required by a bound in this associated function
304 |         client: impl Into<reqwest_middleware::ClientWithMiddleware>,
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AsyncHttpRangeReader::from_head_response`

error[E0277]: the trait bound `reqwest_middleware::client::ClientWithMiddleware: From<RedirectClientWithMiddleware>` is not satisfied
   --> /Users/x/.cargo/git/checkouts/uv-c9e40703e19509a8/f164783/crates/uv-client/src/registry_client.rs:936:38
    |
936 |                       let mut reader = AsyncHttpRangeReader::from_head_response(
    |  ______________________________________^
937 | |                         self.uncached_client(url).clone(),
938 | |                         response,
939 | |                         Url::from(url.clone()),
940 | |                         headers.clone(),
941 | |                     )
    | |_____________________^ the trait `From<RedirectClientWithMiddleware>` is not implemented for `reqwest_middleware::client::ClientWithMiddleware`
    |
    = help: the trait `From<RedirectClientWithMiddleware>` is not implemented for `reqwest_middleware::client::ClientWithMiddleware`
            but trait `From<reqwest::Client>` is implemented for it
    = help: for that trait implementation, expected `reqwest::Client`, found `RedirectClientWithMiddleware`
    = note: required for `RedirectClientWithMiddleware` to implement `Into<reqwest_middleware::client::ClientWithMiddleware>`
note: required by a bound in `AsyncHttpRangeReader::from_head_response`
   --> /Users/x/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async_http_range_reader-0.9.1/src/lib.rs:304:22
    |
303 |     pub async fn from_head_response(
    |                  ------------------ required by a bound in this associated function
304 |         client: impl Into<reqwest_middleware::ClientWithMiddleware>,
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AsyncHttpRangeReader::from_head_response`

error[E0277]: the trait bound `reqwest_middleware::client::ClientWithMiddleware: From<RedirectClientWithMiddleware>` is not satisfied
   --> /Users/x/.cargo/git/checkouts/uv-c9e40703e19509a8/f164783/crates/uv-client/src/registry_client.rs:942:22
    |
942 |                     .await
    |                      ^^^^^ the trait `From<RedirectClientWithMiddleware>` is not implemented for `reqwest_middleware::client::ClientWithMiddleware`
    |
    = help: the trait `From<RedirectClientWithMiddleware>` is not implemented for `reqwest_middleware::client::ClientWithMiddleware`
            but trait `From<reqwest::Client>` is implemented for it
    = help: for that trait implementation, expected `reqwest::Client`, found `RedirectClientWithMiddleware`
    = note: required for `RedirectClientWithMiddleware` to implement `Into<reqwest_middleware::client::ClientWithMiddleware>`
note: required by a bound in `AsyncHttpRangeReader::from_head_response`
   --> /Users/x/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async_http_range_reader-0.9.1/src/lib.rs:304:22
    |
303 |     pub async fn from_head_response(
    |                  ------------------ required by a bound in this associated function
304 |         client: impl Into<reqwest_middleware::ClientWithMiddleware>,
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AsyncHttpRangeReader::from_head_response`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `uv-client` (lib) due to 3 previous errors

I'm not certain if there is anything specific to the Cargo build that makes it work within the uv repo itself -- in the uv repo at the same revision, I'm able to build the project. Both with rustc 1.87 and 1.89.

Cheers,
Felix

Platform

macOS 15.6.1

Version

088c908

Python version

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrustlibRelated to our Rust library API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions