Skip to content

cargo allows pulling non-library dependenciesΒ #8382

Closed
@ignatenkobrain

Description

@ignatenkobrain

Problem

I am not sure if this is bug or a feature (if so, I would appreciate explanation of it)..

The question is about https://crates.io/crates/cargo-insta. From what I see (and what cargo tells me), it has only binary target, no lib / proc or anything like that.

Downloads/rust-cargo-insta/cargo-insta-0.16.0 is πŸ“¦ v0.16.0 via πŸ¦€ v1.44.0 
❯ cargo metadata --no-deps | jq '.packages[0].targets[]'
warning: please specify `--format-version` flag explicitly to avoid compatibility problems
{
  "kind": [
    "bin"
  ],
  "crate_types": [
    "bin"
  ],
  "name": "cargo-insta",
  "src_path": "/home/brain/Downloads/rust-cargo-insta/cargo-insta-0.16.0/src/main.rs",
  "edition": "2018",
  "doctest": false
}

Apparently specifying it in a dependencies section in Cargo.toml pulls it in and even compiles it, but I don't see any final binary (in target/) produced from that crate.

Steps

  1. Add cargo-insta = "0.16" into the [dependencies]
  2. Try to compile a project

Possible Solution(s)

  • Show warning
  • Abort with an error

Notes

Output of cargo version: cargo 1.44.0

This is happening on Fedora 33 (x86_64) with rust/cargo provided by a distribution.

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