Skip to content

Git dependency with a path into a sub-folder location #11858

Open

Description

Problem

I would like to depend on Hashicorp's nomad_client, provided as a Git dependency here: https://github.com/hashicorp/nomad-openapi/blob/main/clients/rust/reqwest/v1/Cargo.toml

The trouble is, Cargo is unable to resolve this dependency reliably, because the repository contains multiple crates named nomad_client:

% cargo build
    Updating git repository `https://github.com/hashicorp/nomad-openapi`
warning: skipping duplicate package `nomad_client` found at `/Users/owen/.cargo/git/checkouts/nomad-openapi-7f8fcd3b1b2636d4/98be39a/clients/rust/hyper/v1`

Today, Cargo happens to select the nomad_client crate that I want, but that could change if the order of traversal changes. (In fact, I think this ambiguity should be a hard error.)

Proposed Solution

If I were able to specify the specific subtree, I would be able to reliably tell Cargo which of the two nomad_client crates to import.

Notes

Hashicorp's own instructions suggest copying the client library into my project, and using a path dependency. This works, but it makes dependency updates much more complicated.

This proposal is similar to #1462. However, the solution in that issue requires that the crate name be unique within the repository. That's not the case here.

Obviously, the Right Answer is for Hashicorp to fix the crate names and ideally even to publish them to Crates.io. I've proposed that here, but I'd like to move forwards while I wait for a response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-crate-dependenciesArea: [dependencies] of any kindArea: [dependencies] of any kindA-gitArea: anything dealing with gitArea: anything dealing with gitC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions