$ 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:
cargo-metadata(1) NAME. cargo-metadata — Machine-readable metadata about the current package. SYNOPSIS. cargo metadata [options]. DESCRIPTION. Output JSON to stdout containing information about the workspace members and resolved dependencies of the current package.
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
I've done this by creating a temporary cargo project and adding a small dependency to it. Something like this:
mkdir /tmp/deleteme \
&& cd /tmp/deleteme \
&& cargo init \
&& cargo add serde \
&& rm -rf /tmp/deleteme
You should immediately see the message:
Updating crates.io index
Whenever a dependency from a git repository is specified without any other specifiers (namely via the properties , rev, or tag), that means that it is specified to the latest revision of the main branch of that repository. But in any case, updating any dependency requires updating the project's Cargo.lock file. This generally means using the branch command.cargo update
cargo update
This will also detect any changes to the version or origin requirements and update the dependency lock accordingly.
I tried to use this command:
cargo install rust_wheel --force
That is the wrong Cargo command. is for installing binaries to the system, not to install dependencies. This is well documented too.cargo install
Also tried
.cargo update rust_wheel
Wrong syntax. To issue an update of a specific dependency, use the option.-p
cargo update -p rust_wheel
See also:
From the guide, will check for updates to itself (in addition to the toolchain updates) every time you run rustup. You could also exclusively update rustup by running rustup update.rustup self update