http-rs / tide

Fast and friendly HTTP server framework for async Rust
https://docs.rs/tide
Apache License 2.0
5.06k stars 321 forks source link

Cargo semver constraints should be narrower #543

Closed jdortiz closed 4 years ago

jdortiz commented 4 years ago

Hi all,

First let me thank you for your work on tide. I am trying to implement a simple REST API with it.

Today I found out that you have updated Tide during the weekend to 0.9.0. I have decided to give it a try and learn what has been added and changed to the crate. However, I haven´t been able to compile it and make it work.

This is the ouput (after cargo clean ): $ cargo run Compiling cfg-if v0.1.10 Compiling libc v0.2.69 Compiling proc-macro2 v1.0.10 Compiling unicode-xid v0.2.0 Compiling syn v1.0.17 Compiling autocfg v1.0.0 Compiling lazy_static v1.4.0 Compiling version_check v0.9.1 Compiling memchr v2.3.3 Compiling scopeguard v1.1.0 Compiling smallvec v1.3.0 Compiling maybe-uninit v2.0.0 Compiling log v0.4.8 Compiling once_cell v1.3.1 Compiling bitflags v1.2.1 Compiling nix v0.17.0 Compiling cc v1.0.50 Compiling futures-core v0.3.5 Compiling serde v1.0.106 Compiling futures-io v0.3.5 Compiling standback v0.2.8 Compiling slab v0.4.2 Compiling pin-utils v0.1.0 Compiling matches v0.1.8 Compiling void v1.0.2 Compiling percent-encoding v2.1.0 Compiling futures-sink v0.3.5 Compiling proc-macro2 v0.4.30 Compiling byteorder v1.3.4 Compiling anyhow v1.0.28 Compiling ryu v1.0.3 Compiling scoped-tls-hkt v0.1.2 Compiling async-task v3.0.0 Compiling proc-macro-hack v0.5.15 Compiling unicode-xid v0.1.0 Compiling syn v0.15.44 Compiling pin-project-lite v0.1.4 Compiling itoa v0.4.5 Compiling rustc-demangle v0.1.16 Compiling httparse v1.3.4 Compiling regex-syntax v0.6.17 Compiling dtoa v0.4.5 Compiling unicode-width v0.1.7 Compiling stable_deref_trait v1.1.1 Compiling data-encoding v2.2.0 Compiling percent-encoding v1.0.1 Compiling mime v0.3.16 Compiling route-recognizer v0.1.13 Compiling lock_api v0.3.4 Compiling thread_local v1.0.1 Compiling futures-task v0.3.5 Compiling unicode-normalization v0.1.12 Compiling unicode-bidi v0.3.4 Compiling unicase v2.6.0 Compiling time v0.2.16 Compiling error-chain v0.12.2 Compiling crossbeam-utils v0.7.2 Compiling memoffset v0.5.4 Compiling crossbeam-epoch v0.8.2 Compiling idna v0.2.0 Compiling aho-corasick v0.7.10 Compiling omnom v2.1.2 Compiling kv-log-macro v1.0.4 Compiling backtrace-sys v0.1.35 Compiling quote v1.0.3 Compiling url v2.1.1 Compiling infer v0.1.6 Compiling mime_guess v2.0.3 Compiling quote v0.6.13 Compiling crossbeam-queue v0.2.1 Compiling crossbeam-channel v0.4.2 Compiling socket2 v0.3.12 Compiling num_cpus v1.12.0 Compiling time v0.1.42 Compiling parking_lot_core v0.7.1 Compiling clicolors-control v1.0.1 Compiling atty v0.2.14 Compiling termios v0.3.2 Compiling crossbeam-deque v0.7.3 Compiling byte-pool v0.2.1 Compiling regex v1.3.7 Compiling parking_lot v0.10.2 Compiling cookie v0.12.0 Compiling crossbeam v0.7.3 Compiling backtrace v0.3.46 Compiling console v0.7.7 Compiling async-log-attributes v1.0.1 Compiling pin-project-internal v0.4.17 Compiling serde_derive v1.0.106 Compiling time-macros-impl v0.1.1 Compiling async-attributes v1.1.1 Compiling async-log v1.1.0 Compiling time-macros v0.1.0 Compiling cookie v0.13.3 Compiling pin-project v0.4.17 Compiling futures-util v0.3.5 Compiling piper v0.1.2 Compiling smol v0.1.10 Compiling async-std v1.6.0 Compiling serde_json v1.0.51 Compiling serde_urlencoded v0.6.1 Compiling serde_qs v0.5.2 Compiling femme v2.0.1 Compiling http-types v2.0.1 Compiling http-types v1.2.0 error[E0308]: mismatched types --> /Users/jorge/.cargo/registry/src/github.com-1ecc6299db9ec823/http-types-1.2.0/src/request.rs:439:9 439 self.receiver.recv().await ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum std::option::Option, found enum std::result::Result
= note: expected enum `std::option::Option<std::result::Result<trailers::Trailers, error::Error>>`
           found enum `std::result::Result<std::result::Result<trailers::Trailers, error::Error>, async_std::sync::channel::RecvError>`
error[E0308]: mismatched types --> /Users/jorge/.cargo/registry/src/github.com-1ecc6299db9ec823/http-types-1.2.0/src/response.rs:404:9 404 self.receiver.recv().await ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum std::option::Option, found enum std::result::Result
= note: expected enum `std::option::Option<std::result::Result<trailers::Trailers, error::Error>>`
           found enum `std::result::Result<std::result::Result<trailers::Trailers, error::Error>, async_std::sync::channel::RecvError>`

error: aborting due to 2 previous errors

For more information about this error, try rustc --explain E0308. error: could not compile http-types.

To learn more, run the command again with --verbose. warning: build failed, waiting for other jobs to finish... error: build failed`

I have then tried to go back to 0.8.1. And after cargo clean and cargo run I get the same errors. This seems to be related to my rustup update. `rustup show Default host: x86_64-apple-darwin rustup home: /Users/jorge/.rustup

stable-x86_64-apple-darwin (default) rustc 1.43.1 (8d69840ab 2020-05-04) `

Is there something I need to do? Thanks again.

Best regards,

Jorge

jdortiz commented 4 years ago

I made a few tests. The poblem seems to be http-types. Version 1.2.x fails to compile with rustc 1.43.1. But http-types 1.3.x (1.3.1) compiles without any problem.

Using Cargo-tree, http types is required by:

Hope this helps a little. I wouldn't mind helping to solve the issue. I just don't know where to start.

Best regards,

Jorge

jdortiz commented 4 years ago

These are the changes in http-types: v.1.2.0 request.rs:

pub async fn recv_trailers(&self) -> Option<crate::Result<Trailers>> {
    self.receiver.recv().await
}

response.rs:

pub async fn recv_trailers(&self) -> Option<crate::Result<Trailers>> {
    self.receiver.recv().await
}

v.1.3.x request.rs:

pub async fn recv_trailers(&self) -> Option<crate::Result<Trailers>> {
    self.receiver.recv().await.ok()
}

response.rs:

pub async fn recv_trailers(&self) -> Option<crate::Result<Trailers>> {
    self.receiver.recv().await.ok()
}

I understand the complain of the compiler and why 1.3.x version is the right one. However, I don't know how to solve the problem with tide other than changing the dependencies of for each of the crates mentioned in my previous comment.

Best regards,

Jorge

jdortiz commented 4 years ago

I have downloaded the source for each of the crates that depend on http-types:

Then I have cheched out the version that was in the dependencies (git checkout tags/) and run cargo build. Funny enough. All of them build successfully. The selected version of http-types is always >= 1.3.1. So, why is it 1.2.0 when I compile my project? I have then cargo update and http-types have moved to 1.3.1. My point is, if 1.2.0 is incompatible, why isn't it uploaded automatically? Shouldn't they all require http-types = "1.3"?

This is my cargo file, btw:

[package]
name = "tide-api"
version = "0.1.0"
authors = ["Me"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
async-std = { version = "1.5.0", features = ["attributes"] }
tide = "0.9"

Best regards,

Jorge

jbr commented 4 years ago

I believe you need to switch to async-std 1.6.0 and run cargo update

jdortiz commented 4 years ago

Thank you @jbr! As I mentioned in my last message, It worked with async-std 1.5 in Cargo.toml. It was actually downloading 1.6. My final comment, and what I belive should be solved, is that some configurations that don't compile are allowed by the version of http-types in the 5 crates mentioned above. My question is then, should we update the dependencies in those to reflect the fact that at least 1.3 is required for http-types to successfully compile?

Best regards,

Jorge

jbr commented 4 years ago

I'm not sure what the next step is for this issue. Is the concern that people need to run cargo update? Or that it is possible to specify conflicting versions that are caught by the compiler instead of by cargo's semver?


Please update the title of this issue if I mischaracterized the concern

jbr commented 4 years ago

Closing because this seems to be more of a cargo issue than a tide issue, if I understand the concern