$ cargo new hello_world Cargo defaults to --bin to make a binary program. To make a library, we would pass --lib, instead. Let’s check out what Cargo has generated for us: $ cd hello_world $ tree . . ├── Cargo.toml └── src └── main.rs 1 directory, 2 files This is all we need to get started. First, let’s check out Cargo.toml:
json-render-diagnostics: Instruct Cargo to not include rustc diagnostics in JSON messages printed, but instead Cargo itself should render the JSON diagnostics coming from rustc. Cargo’s own JSON diagnostics and others coming from rustc are still emitted. Cannot be used with human or short.--build-plan
You should update and rustc based on how you installed it. If you used rustup, a cargo should suffice. If you used a package manager or a binary installer, check those sources for an update.rustup update
and rustc are shipped together, but that doesn't mean that their versions need to match. In fact, they do not match until Rust 1.26.0, when the Cargo binary was changed to print the Rust version.cargo
I have the same versions of and rustc that you do; those are the ones that correspond to the Rust 1.9 release. There's nothing to worry about.cargo
If you really want to, you can download a nightly version of Cargo or compile your own. As long as your version exists in your before the older one, it will be used.PATH
I used to do this with my local Rust builds in order to have a version of Cargo at all, although rustup now automatically uses the from the most recent stable version when there isn't one available in the current toolchain, which is nice.cargo