Skip to content

cargo install exits with success code on partial failures #9180

@horacimacias

Description

@horacimacias

Problem
cargo install exits with success code when installing a list of crates, even if some of them failed.
As a result, anybody running cargo install crate1 crate2 will get a false sense of success if one of the crates failed to install. For example Dockerfiles running such commands will not fail to build, which means the resulting container image does not contain all the crates one hopes to find installed, since cargo install still exited with success code.

Steps

  1. cargo install a list of crates where at least 1 fails and at least 1 succeeds. Right now I used cargo install --force cargo-sweep cargo-deny for example (as cargo-deny has issues installing without --locked; see Build failure due to bitvec dependency EmbarkStudios/cargo-deny#331 for details although the reason for failure is irrelevant to the issue reported here)
  2. Check the last command exit code. it should be non-zero but it is zero.

Possible Solution(s)
Perhaps it's better to succeed only if all requested crates were successfully installed.
As a side note, documentation for cargo install should be updated to reflect the behaviour, either current or future.

Notes

Output of cargo version:

cargo 1.49.0 (d00d64d 2020-12-05)
OSX using stable channel

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions