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

REST API example may break due to versioning shenanigans #618

Open
ben0x539 opened this issue Nov 10, 2020 · 3 comments · May be fixed by #707
Open

REST API example may break due to versioning shenanigans #618

ben0x539 opened this issue Nov 10, 2020 · 3 comments · May be fixed by #707
Assignees
Labels

Comments

@ben0x539
Copy link

A pal just ran into this and was stumped: If you copy the first example from web/clients/api/rest-get.md into a new cargo binary project and add the latest versions of reqwest and tokio to your Cargo.toml so it builds, you panic because #[tokio::main] is coming from a different tokio than what reqwest uses, so the reqwest calls are supposedly not on a tokio runtime.

You can probably figure out what is going on from googling the error message, but I suspect someone browsing a cookbook for examples to play with may not be up for package version debugging. idk if there's a robust way to save people from this terrible fate. :(

@AndyGauge
Copy link
Collaborator

We've had similar insights into other recipes. We've tried to avoid that two ways: 1 there's a cargo.toml file in the cookbook https://github.com/rust-lang-nursery/rust-cookbook/blob/master/Cargo.toml but it isn't very discoverable. 2. We put badges on the recipies to help people know which crates to import. This recipe was originally authored for synchronous reqwest. when it was updated, the tokio badge wasn't added. I think adding the tokio badge to the updated recipes would be a good solution.

@dogweather
Copy link

dogweather commented Jan 3, 2021

I just ran into this. @AndyGauge you're right — I wished I had a Cargo.toml file to go with the code, because I tried many combinations of specifying the dependencies, and couldn't get it working.

If the only thing keeping this from working is correct toml configuration, could we add a link to it from a page header or footer? To me, the code is incomplete without it.

@dogweather
Copy link

@AndyGauge Ok, that doesn't work: naively using https://github.com/rust-lang-nursery/rust-cookbook/blob/master/Cargo.toml with the sample code at https://rust-lang-nursery.github.io/rust-cookbook/web/clients/requests.html:

error: couldn't read build.rs: No such file or directory (os error 2)

error: aborting due to previous error

error: could not compile `rust-cookbook`

This example also doesn't work via the arrow button to run via the web. I think it's safe to say that many examples in the cookbook are broken. Has there been thinking about automated testing?

@AndyGauge AndyGauge linked a pull request Nov 30, 2024 that will close this issue
11 tasks
@AndyGauge AndyGauge self-assigned this Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants