actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.39k stars 1.17k forks source link

Include .crates.toml in Rust example #1167

Open tommy-gilligan opened 1 year ago

tommy-gilligan commented 1 year ago

Description

Using the existing example, cargo install will error out after restoring a cache:

cargo install cargo-tarpaulin
    Updating crates.io index
error: binary `cargo-tarpaulin` already exists in destination
Add --force to overwrite
Error: Process completed with exit code 101.

--force is undesirable because it will recompile the binary. Cargo is scared of the existing binary because it doesn't have enough information about it. Including ~/.cargo/.crates.toml coaxes it into being okay with the situation.

Motivation and Context

Caching cargo install PACKAGE errors with

error: binary `PACKAGE` already exists in destination

This can be circumvented by using --force but this negates any benefit of using the cache.

How Has This Been Tested?

I am using the example with this change on my own private repo successfully.

Types of changes

Checklist:

LucasFA commented 4 months ago

The cargo book also suggests caching .crates2.json, too book.

Either cache them or don't include the bin directory - current example is indeed broken