To start a new package with Cargo, use cargo new: $ 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
cargo-build — Compile the current package. SYNOPSIS. cargo build [options] DESCRIPTION. Compile local packages and all of their dependencies. OPTIONS Package Selection. By default, when no package selection options are given, the packages selected depend on the selected manifest file (based on the current working directory if --manifest-path ...
As of Rust 1.41.0, you can use the following command to update crates to their latest version:
cargo install <crate>
This came from pull request #6798 (Add install-upgrade) and was stabilized in #7560 (Stabilize install-upgrade).
Instead of failing when detects a package is already installed, it will upgrade if the versions don't match, or do nothing (exit 0) if it is considered "up-to-date".cargo install
The following command will always uninstall, download and compile the latest version of the crate - even if there's no newer version available. Under normal circumstances the feature should be preferred as it does save time and bandwidth if there's no new version of the crate.install-upgrade
cargo install --force <crate>
Further information can be found in the GitHub issue rust-lang/cargo#6797 and in the official documentation chapter.
I believe that file is just for the built-in libraries, i.e. those distributed with manifest. rustc itself stores things in cargo (for the moment), if you do wish to just remove all the libraries then deleting that directory won't break anything.~/.cargo
If you're just wanting to rebuild/update dependencies you can run cargo.cargo update