Tag: package

All about Rust Cargo commands

Cargo is Rust’s build system and package manager. Most developers use this tool to manage their Rust projects because Cargo handles a lot of tasks for you, such as building your code, downloading the libraries your code depends on, and building those libraries.

Cargo commands and its usage-

Check the cargo version

cargo --version

Create a new project

Create a new project using Cargo.

cargo new <<project_name>>

Build the Cargo project

Build command compiles the project and create’s an executable file in /debug/ folder. Running the cargo build command updated the Cargo.lock file which keeps the trakc of exact version of dependecies in the project.

cargo build

Running a Cargo project

Cargo run compiles the project and runs the resultant executable all in one command. So instead of remembering the cargo build and path to execute the excutable, Cargo run does both for you which is more conveninent

cargo run

Check your code

If you want to quickly check if the code to make sure it complies susccesfully without using build or run command, you can use check command. This nmusch faster than build because it skips the step to create an executable.

cargo check

Update the project dependencies

Update the dependeincies of you project using update command. This ignores the Cargo.lock file which has all the dependencies. update command will look for one higher version than current version e..g: if the current version is 0.7.5 and the latest version is 0.8.0. But if there is next higher version i.e. 0.7.6, then update command will udpate the dependency to 0.7.6. Also after update the Cargo.lock file is udpated.

If you want to jump to a specific version, as per above case to 0.8.0. Update hte Cargo.toml file dependencies section.

cargo update

Reference – https://doc.rust-lang.org/cargo/

This is WIP, there is lot more to add here.

Loading

Ubuntu – Package Management

DPKG – Debian Package Manager used to install, uninstall, list and check the status of the package

It comes with .deb file.

DPKG does not honour dependecies hence we need to use APT for Ubuntu

APT stands for Advanced Packaging Tool and relies on DPKG

Use apt update command to refresh the repository-

sudo apt update

Use apt upgrade to upgrade exisitng package-

sudo apt upgrade

To install a package-

sudo apt install <package name>

To uninstall or remove package-

sudo apt remove <package name>

To search package e.g:- python-dev

sudo apt search python-dev

To list all the packages in repository-

sudo apt list