-
Notifications
You must be signed in to change notification settings - Fork 222
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
doc: how to run example, for n00bs #476
Comments
I would change: |
now the question is why? |
TL;DR: Wildcards in your dependencies can be dangerous and make Cargo do it's best to guess what you really want. A lone "*" means "every version ever" and is especially dangerous because it encompasses breaking changes across versions. Standard practice is to use version numbers (you can check crates.io), as those are the published versions.I believe the issue stems from using a wildcard field ("*") for a dependency in the Cargo.toml. On first run (i.e. absence of a Cargo.lock) Cargo adds all the dependencies you asked for in the Cargo.toml to the resolution list. In this particular case It looks like this: html5ever = "*" // ANY version will do, newest is 0.26 on crates.io, add it and use it for our own code
markdown5ever_rcdom = "*" // ANY version will do, newest is 0.1, add it and use it for our own code We then resolve the dependencies of our dependencies (turtles all the way down): Now the rub: we have two things with the same names with breaking changes between their versions. Our own code will resolve to what we asked for in the toml, which at the time resolved to 0.26. After that the breaking changes between 0.25<->0.26, well, break, and we get the error. Now why does changing the name of the project work?This seemed crazy at first but here is what I believe is happening: html5ever = "*" // ANY version will do, including 0.25.2 which we already know we need, just use it With no mention, specifically, of needing 0.26 (only a "*"), all our requirements have been filled. 0.25.2 is used for our own code and 0.26 is removed from the list. As an aside, the readme.md in rcdom seems to be trying to ward off people from using it at all. One might stray away from leveraging it early (or ever?) in a rust learning journey. |
Re: #475
rustc
version is1.61.0
or greaterrustup update rustup override unset rustup default stable rustc --version
mkdir -p ./my-print-rcdom/ pushd ./my-print-rcdom/ cargo init
Cargo.toml
to include the dependencies (also,2018
appears to be the required edition)src/main.rs
with the contents of, for example,./rcdom/examples/print-rcdom.rs
cargo build curl https://example.com | cargo run
Troubleshooting
Weird bug:
Changing the
name
field inCargo.toml
(to anything at all), saving, and runningcargo install
again.A room full of rust developers, including one of the most popular teachers on udemy in the room here with us, cannot figure this out.
The text was updated successfully, but these errors were encountered: