sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.49k stars 443 forks source link

Unable to build tokio-postgres 0.7.7 #956

Closed gerob311 closed 1 year ago

gerob311 commented 2 years ago

I'm using rust-postgres as a dependency for my project, and I'm getting the following error when I build my project.

error[E0432]: unresolved imports `futures_util::Future`, `futures_util::Stream`
 --> /Users/gerob/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-postgres-0.7.7/src/connect.rs:7:37
  |
7 | use futures_util::{future, pin_mut, Future, FutureExt, Stream};
  |                                     ^^^^^^             ^^^^^^ no `Stream` in the root
  |                                     |
  |                                     no `Future` in the root
  |
help: a similar name exists in the module
  |
7 | use futures_util::{future, pin_mut, future, FutureExt, Stream};
  |                                     ~~~~~~
help: a similar name exists in the module
  |
7 | use futures_util::{future, pin_mut, Future, FutureExt, stream};
  |   

There seems to be similar problems with the case of imports of Stream and Future in

I'd expect that a released crate would build so, what might I be doing wrong?

sfackler commented 2 years ago

Both of those imports definitely exist: https://docs.rs/futures-util/latest/src/futures_util/lib.rs.html#300. Are you sure you aren't using a patched version of futures-util?

gerob311 commented 2 years ago

Not that I'm aware of. Here's my dependencies list:

[dependencies]
chrono = { version = "0.4.22", features = ["serde"] }
chrono-tz = { version = "0.6.3", features = ["serde"] }
serde = { version = "~1.0", features = ["derive"] }
serde_json = { version = "~1.0.59", features = ["raw_value"] }
log = "~0.4.11"
simple_logger = "~2.3.0"
postgres = "0.19.4"
postgres-types = { version = "0.2.4", features = ["derive"] }
r2d2 = "~0.8.10"
r2d2_postgres = "~0.18.1"
rocket = { version = "0.5.0-rc.2", features = ["json"] }

I've tried commenting out every dependency except postgres = "0.19.4", and running cargo clean then cargo build, and I'm still getting the same problem. I'm not sure what else to try.

In case it helps, I'm using rustc 1.64.0, and I'm using the 2018 rust edition.

Looking at the link you posted, does Stream need to be imported as stream::Stream? That might be naive of me, I'm still not confident with Rust's import usage.

sfackler commented 2 years ago

You could try deleting your Cargo cache to see if the source of the futures_util crate was modified or corrupted locally.

gerob311 commented 2 years ago

I have now tried deleting my Cargo cache, and I am getting the same problem, when postgres = "0.19.4 is my only dependency. Does that mean it needs to be fixed on crates.io?

sfackler commented 2 years ago

I cannot reproduce your issue locally. It is highly unlikely that anything needs to be fixed on crates.io.

palfrey commented 1 year ago

I've just hit this. The problem is that tokio-postgres says it depends on 0.3 of futures-util but in some 0.3.x versions (e.g. 0.3.13) it's not present.

palfrey commented 1 year ago

Setting the minimum to 0.3.14 seems to fix things though