Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include .crates.toml in Rust example #1167

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tommy-gilligan
Copy link

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (add or update README or docs)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

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.
@tommy-gilligan tommy-gilligan requested a review from a team as a code owner May 4, 2023 06:42
@LucasFA
Copy link

LucasFA commented Mar 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants