Skip to content

Commit 9655d70

Browse files
committed
Auto merge of #7348 - ehuss:fix-vendor-link, r=alexcrichton
Home docs: fix broken links, misspellings, style fixes, clarifications. A broken link blocking upstream update. Made some other fixes while reviewing it.
2 parents d41f4af + 57b3d04 commit 9655d70

File tree

1 file changed

+42
-36
lines changed

1 file changed

+42
-36
lines changed

src/doc/src/guide/cargo-home.md

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
## Cargo Home
22

3-
The cargo home functions as a download and source cache.
4-
When building a crate, cargo stores downloaded build dependencies in the cargo home.
5-
You can alter the location of the cargo home by setting the `CARGO_HOME` [environmental variable](../reference/environment-variables.html).
6-
The [home](https://crates.io/crates/home) crate provides an api for getting this location if you need this information inside your rust crate.
7-
By default, the cargo home is located in `${HOME}/.cargo/`.
3+
The "Cargo home" functions as a download and source cache.
4+
When building a crate, Cargo stores downloaded build dependencies in the Cargo home.
5+
You can alter the location of the Cargo home by setting the `CARGO_HOME` [environmental variable][env].
6+
The [home](https://crates.io/crates/home) crate provides an API for getting this location if you need this information inside your Rust crate.
7+
By default, the Cargo home is located in `$HOME/.cargo/`.
88

9-
Please note that the internal structure of the cargo home is not stabilized and may be subject to change at any time.
9+
Please note that the internal structure of the Cargo home is not stabilized and may be subject to change at any time.
1010

11-
The cargo home consists of following components:
11+
The Cargo home consists of following components:
1212

1313
## Files:
1414

15-
* `config`
16-
Cargos global configuration file, see the [config entry in the reference](../reference/config.html).
15+
* `config`
16+
Cargo's global configuration file, see the [config entry in the reference][config].
1717

18-
* `credentials`
19-
Private login credentials from [`cargo login`](../commands/cargo-login.html) in order to login into a registry.
18+
* `credentials`
19+
Private login credentials from [`cargo login`] in order to log in to a registry.
2020

2121
* `.crates.toml`
22-
This hidden file contains package information of crates installed via [cargo install](../commands/cargo-install.html). Do NOT edit by hand!
22+
This hidden file contains package information of crates installed via [`cargo install`]. Do NOT edit by hand!
2323

2424
## Directories:
2525

26-
* `bin`
27-
The bin directory contains executables of crates that were installed via "cargo install" or `rustup`.
28-
To be able to make these binaries accessible, add the path of the directory to your `${PATH}`.
26+
* `bin`
27+
The bin directory contains executables of crates that were installed via [`cargo install`] or [`rustup`](https://github.com/rust-lang/rustup.rs).
28+
To be able to make these binaries accessible, add the path of the directory to your `$PATH` environment variable.
2929

30-
* `git`
30+
* `git`
3131
Git sources are stored here:
32-
33-
* `git/db`
34-
When a crate depends on a git repository, cargo clones the repo as a bare repo into this directory and updates it if neccessary.
35-
36-
* `git/checkouts`
32+
33+
* `git/db`
34+
When a crate depends on a git repository, Cargo clones the repo as a bare repo into this directory and updates it if necessary.
35+
36+
* `git/checkouts`
3737
If a git source is used, the required commit of the repo is checked out from the bare repo inside `git/db` into this directory.
3838
This provides the compiler with the actual files contained in the repo of the commit specified for that dependency.
3939
Multiple checkouts of different commits of the same repo are possible.
4040

41-
* `registry`
42-
Packages and metadata of crate registries (such as crates.io) are located here.
43-
44-
* `registry/index`
41+
* `registry`
42+
Packages and metadata of crate registries (such as [crates.io](https://crates.io/)) are located here.
43+
44+
* `registry/index`
4545
The index is a bare git repository which contains the metadata (versions, dependencies etc) of all available crates of a registry.
4646

47-
* `registry/cache`
47+
* `registry/cache`
4848
Downloaded dependencies are stored in the cache. The crates are compressed gzip archives named with a `.crate` extension.
49-
50-
* `registry/src`
49+
50+
* `registry/src`
5151
If a downloaded `.crate` archive is required by a package, it is unpacked into `registry/src` folder where rustc will find the `.rs` files.
5252

5353

54-
## Caching the cargo home in CI
54+
## Caching the Cargo home in CI
5555

56-
To avoid redownloading all crate dependencies during continuous integration, you can cache the `$CARGO_HOME` directory.
57-
However, caching the entire directory as is is often inefficient as it will contain downloaded sources twice.
58-
If we depend on `cargo 0.38.0` and cache the entire `$CARGO_HOME` we would actually cache the sources twice, the `cargo-0.38.0.crate` inside `registry/cache` and the extracted `.rs` files of cargoinside `registry/src`.
59-
The can unneccessarily slow down the build as downloading, extracting, recompressing and reuploading the cache ot the CI servers can take some time.
56+
To avoid redownloading all crate dependencies during continuous integration, you can cache the `$CARGO_HOME` directory.
57+
However, caching the entire directory is often inefficient as it will contain downloaded sources twice.
58+
If we depend on a crate such as `serde 1.0.92` and cache the entire `$CARGO_HOME` we would actually cache the sources twice, the `serde-1.0.92.crate` inside `registry/cache` and the extracted `.rs` files of serde inside `registry/src`.
59+
The can unnecessarily slow down the build as downloading, extracting, recompressing and reuploading the cache to the CI servers can take some time.
6060

6161
It should be sufficient to only cache the following directories across builds:
6262

@@ -69,12 +69,18 @@ It should be sufficient to only cache the following directories across builds:
6969

7070
## Vendoring all dependencies of a project
7171

72-
See the [cargo vendor](commands/cargo-vendor.md) subcommand.
72+
See the [`cargo vendor`] subcommand.
7373

7474

7575

7676
## Clearing the cache
7777

78-
In theory, you can always remove any part of the cache and cargo will do its best to restore sources if a crate needs them either by reextracting an archive or checking out a bare repo or by simply redownloading the sources from the web.
78+
In theory, you can always remove any part of the cache and Cargo will do its best to restore sources if a crate needs them either by reextracting an archive or checking out a bare repo or by simply redownloading the sources from the web.
79+
80+
Alternatively, the [cargo-cache](https://crates.io/crates/cargo-cache) crate provides a simple CLI tool to only clear selected parts of the cache or show sizes of its components in your command-line.
7981

80-
Alternatively, the [cargo-cache](https://crates.io/crates/cargo-cache) crate provides a simple CLI tool to only clear selected parts of the cache or show sizes of its components in your commandline.
82+
[`cargo install`]: ../commands/cargo-install.md
83+
[`cargo login`]: ../commands/cargo-login.md
84+
[`cargo vendor`]: ../commands/cargo-vendor.md
85+
[config]: ../reference/config.md
86+
[env]: ../reference/environment-variables.md

0 commit comments

Comments
 (0)