Where does Cargo put the git requirements?

2019-08-10 11:52发布

问题:

When compiling a project, cargo automatically downloads the requirements, specified in the Cargo.toml, given as a git-repository.

E.g.

[dependencies.piston]
git = "https://github.com/PistonDevelopers/piston"

will result in

Updating git repository 'https://github.com/PistonDevelopers/opengl_graphics'

when compiling. Where does it save those repositories on my disk? I'm using Windows, does this change anything?

回答1:

man cargo gives:

FILES
       ~/.cargo
              Directory  in which Cargo stores repository data. Cargo can
              be instructed to use a .cargo subdirectory in  a  different
              location by setting the CARGO_HOME environment variable.

Doing a git grep for CARGO_HOME finds https://github.com/rust-lang/cargo/blob/3533ff11c505017751d1e466685efe7084cbd96b/src/cargo/util/config.rs#L380-L384

which uses http://doc.rust-lang.org/nightly/std/os/fn.homedir.html