mirror of
https://github.com/darkicewolf50/RustBrock.git
synced 2025-07-26 12:56:00 -06:00
.gitea
.github
.obsidian
HelloWorld
adder
branches
functions_rust
guessing_game
hello_cargo
loops
minigrep
ownership
rectangles
.gitignore
Cargo Workspaces.md
Cargo and Cratesio.md
Closures.md
Collection of Common Data Structs.md
Constants.md
Crates.md
Custome Build Profiles.md
Data Types.md
Enums.md
Error Handling.md
Extending Cargo.md
For later baja.md
Generic Types Traits and Lifetimes.md
Generics.md
Hash.md
Improving The IO Project.md
Install Binaries.md
Iterators and Closures.md
Iterators.md
Lifetimes.md
Modules and Use.md
Packages.md
Paths.md
Primitives.md
Project Organization.md
Publishing libraries.md
README.md
Reducing_Code_Duplication.md
RustBrock.code-workspace
String.md
Structures.md
Test Controls.md
Test_Organization.md
Tests.md
The Performance Closures and Iterators.md
Traits.md
Variables.md
Vector.md
Writing_Tests.md
data_types.md
ownership.md
45 lines
1.8 KiB
Markdown
45 lines
1.8 KiB
Markdown
# Installing Binaries with `cargo install`
|
|
This is a commnad that allows you to install and use binary crates locally.
|
|
|
|
This is not a replacement for system packages.
|
|
|
|
It should be instead intended to be a convenient way for Rust devs to install tools that others have shared on [crates.io](https://crates.io)
|
|
|
|
Note that you can only install packages that have binary targets
|
|
|
|
A *binary target* is the runnable program that is created if the crate has a *src/main.rs* file or anthoer file specified as a binary.
|
|
|
|
This is unlike a binary target that isnt unnable on its own but is suitable for including within other programs.
|
|
|
|
Usucally crates have information in the *README* file about whether a crate is a library, has a binary target, or both.
|
|
|
|
All binaries installed with `cargo install` are saved in the installation root's *bin* folder.
|
|
|
|
If you installed Rust using *rustup.rs* and dont have any custom configs.
|
|
|
|
This file would be *$HOME/.cargo/bin*.
|
|
|
|
To be able to run programs you installed with `cargo install`, you must ensure that this directory is in your `$PATH`
|
|
|
|
For example to install `ripgrep` (Rust's implementation of the `grep` tool) which searches files.
|
|
|
|
To install this run the following
|
|
```
|
|
$ cargo install ripgrep
|
|
Updating crates.io index
|
|
Downloaded ripgrep v13.0.0
|
|
Downloaded 1 crate (243.3 KB) in 0.88s
|
|
Installing ripgrep v13.0.0
|
|
--snip--
|
|
Compiling ripgrep v13.0.0
|
|
Finished `release` profile [optimized + debuginfo] target(s) in 10.64s
|
|
Installing ~/.cargo/bin/rg
|
|
Installed package `ripgrep v13.0.0` (executable `rg`)
|
|
```
|
|
The second last line of shows the location and the name of the installed binary.
|
|
|
|
In the case of `ripgrep` is `rg`.
|
|
|
|
As long as the install directory is in the `$PATH`, you can then run `rg --help`.
|
|
|
|
Then you can start using a faster, rustier tool for searching files! |