Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Job failing on trying to cargo install already existing crate #219

Open
2 of 3 tasks
mr-pascal opened this issue Nov 12, 2022 · 1 comment
Open
2 of 3 tasks

Job failing on trying to cargo install already existing crate #219

mr-pascal opened this issue Nov 12, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@mr-pascal
Copy link

mr-pascal commented Nov 12, 2022

Do the checklist before filing an issue:

Description

On my GitHub Actions CI pipeline the actin-rs/cargo@v1 errors using the install command when, due to caching, the target crate is already installed.

Workflow code

My Workflow file:
https://github.com/mr-pascal/changelog-generator/actions/runs/3451578950/workflow
See the test_coverage job workflow.

# Install "grcov"
- uses: actions-rs/cargo@v1
  with:
    command: install
    args: grcov

Action output

Run actions-rs/cargo@v1
  with:
    command: install
    args: grcov
    use-cross: false
  env:
    RUSTFLAGS: -Cinstrument-coverage
    LLVM_PROFILE_FILE: coverage-%p-%m.profraw
/home/runner/.cargo/bin/cargo install grcov
    Updating crates.io index
error: binary `grcov` already exists in destination
Error: Add --force to overwrite
Error: The process '/home/runner/.cargo/bin/cargo' failed with exit code 101

Expected behavior

Instead of throwing an error and failing the job I would expect a plain "Ignored" notice, that the package already exists and the job just continues.

image

Additional context

I use caching in the workflow to speed it up significantly, as such also the previous installed grcov is kept in cache and available.

- uses: actions/cache@v3
  with:
    path: |
      ~/.cargo/bin/
      ~/.cargo/registry/index/
      ~/.cargo/registry/cache/
      ~/.cargo/git/db/
      target/
    key: ${{ runner.os }}-cargo-2-${{ hashFiles('**/Cargo.lock') }}

Using --force and just re-installing the crate is no option, since this would introduce also a re-compilation of the crate.

@mr-pascal mr-pascal added the bug Something isn't working label Nov 12, 2022
@mr-pascal
Copy link
Author

ℹ️
As a workaround I used some tiny shell magic to check if it is installed and if not, install it:

if ! which grcov; then cargo install grcov; fi

Even though it would be way better and cleaner if I could use the action-rs/cargo way instead of falling back to shell scripting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant