Skip to content

cargo add <crate> --git=<repo> -F <feature> results in "error: unrecognized feature for crate <crate>" for crates in a workspace #13542

Closed as not planned
@digikata

Description

@digikata

Problem

For crates in a workspace, cargo add with a git flag and feature flag results in an "unrecognized feature" error.
The error occurs if the dependency is being newly added or updated.

Discovered in the fluvio repository CI, but other workspace organized repositories seem to show the same problem.

Steps

  1. cargo init .
  2. cargo add fluvio --git=https://github.com/infinyon/fluvio.git -F admin
    error: unrecognized feature for crate fluvio: admin
    no features available for crate fluvio
  3. Manually adding the dependency line to Cargo.toml works fine:
    fluvio = { features = ["admin"], git = "https://github.com/infinyon/fluvio.git" }

Possible Solution(s)

Manually adding the dependency works fine.

Notes

Other repos with using a workspace fail in the same way:

$ cargo add tokio --git=https://github.com/tokio-rs/tokio.git -F io-util
    Updating git repository `https://github.com/tokio-rs/tokio.git`
      Adding tokio (git) to dependencies.
error: unrecognized feature for crate tokio: io-util

Repos that are not workspace organized seem to work fine:

cargo add anyhow --git https://github.com/dtolnay/anyhow -F backtrace
    Updating git repository `https://github.com/dtolnay/anyhow`
      Adding anyhow (git) to dependencies.
             Features:
             + backtrace
             + std

Version

cargo 1.76.0 (c84b36747 2024-01-18)
release: 1.76.0
commit-hash: c84b367471a2db61d2c2c6aab605b14130b8a31b
commit-date: 2024-01-18
host: aarch64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0 (sys:0.4.70+curl-8.5.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 14.2.1 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-gitArea: anything dealing with gitC-bugCategory: bugCommand-addS-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions