Skip to content

Suggested cache set is insufficient for cargo install #8841

Closed
@wchargin

Description

@wchargin

From the “Cargo Home” docs page (live, source), referring to what
directories should be cached in CI:

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

  • bin/
  • registry/index/
  • registry/cache/
  • git/db/

This doesn’t seem to be sufficient when the job runs cargo install to
install tools, like Cargo subcommands (e.g., cargo-raze). If a job
installs a binary and only caches these directories, a re-run of the job
will fail at cargo install time with

error: binary `cargo-raze` already exists in destination
Add --force to overwrite

because the binary exists but Cargo has no record that it has been
installed. Sample failure:
https://github.com/tensorflow/tensorboard/runs/1367174061

It sufficed for me to also cache .crates.toml and .crates2.json.
Maybe only the former is needed; I included the latter to be safe.
Especially since these are dotfiles, it would be nice to document that
they, too, should be cached.

I would submit a patch, but I don’t know exactly what the right
recommendation is.


cargo version 1.47.0 on Linux (Debian/Ubuntu)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions