Skip to content

Separate error code for cargo install failing due to binary already installed #11513

Closed
@djeedai

Description

@djeedai

Problem

I'm trying to use cargo install in CI on GitHub, to install cargo-tarpaulin. However cargo install might fail if the CI agent already has the version of cargo-tarpaulin that I need. Since it takes a bit to install, I also want to use GitHub caching, so want to avoid --force. However, I still want to fail CI if the install fails for any other reason than "the version is already installed". Unfortunately cargo returns a single error code so there's no way for me to discriminate those two failures, and no easy way that I know of either to check if a binary is installed (cargo install --list is hard to parse via script due to its nested listing which outputs both the package and its binaries, which are often the same).

Proposed Solution

Have cargo return a different error code when not using --force and the version of the binary is already installed.

Notes

Briefly discussed on Discord here.

Metadata

Metadata

Assignees

Labels

A-documenting-cargo-itselfArea: Cargo's documentationC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`E-easyExperience: Easy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions