cargo

(★ 15,405)

The Rust package manager

File Explorer

Showing a partial file list — download the zip above to see everything.

  • .git-blame-ignore-revs
  • .gitignore
  • .ignore
  • build.rs
  • Cargo.lock
  • Cargo.toml
  • CHANGELOG.md
  • clippy.toml
  • CODE_OF_CONDUCT.md
  • CONTRIBUTING.md
  • deny.toml
  • LICENSE-APACHE
  • LICENSE-MIT
  • LICENSE-THIRD-PARTY
  • publish.py
  • README.md
  • rustfmt.toml

# Installation Guide

rust
Prerequisites

Setup Steps

git clone https://github.com/rust-lang/cargo.git

Clone the repository.

cd cargo

Change directory to the project folder.

cargo build --release

Build the project in release mode.

Key Commands

cargo build --release

Build the optimized release binary.

cargo test

Run the test suite for the project.

Ensure OpenSSL development packages are installed on your system for a successful build.

# Use via CDN

jsDelivr

jsDelivr serves any public GitHub repository as a CDN with zero setup. Pick a version and a file to get a ready-to-paste link and snippet.

Showing a partial file list.

Command Glossary

Commands referenced in this DOCs, explained below.

🔍

cargo build

View Details ▼

Compile a local package and all of its dependencies.

cargo {{[b|build]}}

Build the package or packages defined by the `Cargo.toml` manifest file in the local path:

cargo {{[b|build]}} {{[-r|--release]}}

Build artifacts in release mode, with optimizations:

cargo {{[b|build]}} --locked

Require that `Cargo.lock` is up to date:

🔍

cargo

View Details ▼

Manage Rust projects and their module dependencies (crates).
Some subcommands such as `build` have their own usage documentation.

cargo search {{search_string}}

Search for crates:

cargo install {{crate_name}}

Install a binary crate:

cargo install --list

List installed binary crates:

🔍

git clone

View Details ▼

Clone an existing repository.

git clone {{remote_repository_location}} {{path/to/directory}}

Clone an existing repository into a new directory (the default directory is the repository name):

git clone --recursive {{remote_repository_location}}

Clone an existing repository and its submodules:

git clone {{[-n|--no-checkout]}} {{remote_repository_location}}

Clone only the `.git` directory of an existing repository:

🔍

git

View Details ▼

Distributed version control system.
Some subcommands such as `commit`, `add`, `branch`, `switch`, `push`, etc. have their own usage documentation.

git init

Create an empty Git repository:

git clone {{https://example.com/repo.git}}

Clone a remote Git repository from the internet:

git status

View the status of the local repository:

🔍

openssl

View Details ▼

OpenSSL cryptographic toolkit.
Some subcommands such as `req` have their own usage documentation.

openssl genpkey -algorithm {{rsa|ec}} -out {{path/to/private.key}} -aes256

Generate a private key and encrypt the output file using AES-256:

openssl rsa -in {{path/to/private.key}} -pubout -out {{path/to/public.key}}

Generate the corresponding public key from the private key `private.key` using `rsa`:

openssl req -new -x509 -key {{path/to/private.key}} -out {{path/to/certificate.crt}} -days 365

Generate a self-signed certificate valid for a specified number of days (365):

🔍

perl

View Details ▼

The Perl 5 language interpreter.
See also: `perldoc`.

perl -n -e 'print if m/regex1/ and m/regex2/i'

Print lines from `stdin` [m]atching `regex1` and case [i]nsensitive `regex2`:

perl -n -E 'say $1 if m/{{before}} ( {{group_regex}} ) {{after}}/x'

Say ([-E]) first match group, using a `regex`, ignoring space ([x]) in `regex`:

perl -i'.bak' -p -e 's/regex/{{replacement}}/g' {{path/to/files}}

[i]n-place, with backup, [s]ubstitute all occurrence ([g]) of `regex` with a replacement:

🔍

pkg-config

View Details ▼

Provide the details of installed libraries for compiling applications.

pkg-config --libs {{library1 library2 ...}}

Get the list of libraries and their dependencies:

pkg-config --cflags --libs {{library1 library2 ...}}

Get the list of libraries, their dependencies, and proper cflags for gcc:

pkg-config --modversion {{module1 module2 ...}}

Print the version of the linked modules:

🔍

rustc

View Details ▼

The Rust compiler.
Rust projects usually use `cargo` instead of invoking `rustc` directly.

rustc {{path/to/main.rs}}

Compile a binary crate:

rustc {{[-C|--codegen]}} lto {{[-C|--codegen]}} opt-level={{0|1|2|3|s|z}} {{path/to/main.rs}}

Compile with optimizations (`s` means optimize for binary size; `z` is the same with even more optimizations):

rustc {{[-g|--codegen debuginfo=2]}} {{path/to/main.rs}}

Compile with debugging information:

// repository documentation