Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ojacobson opened this issue Mar 15, 2023 · 1 comment
Open

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

ojacobson opened this issue Mar 15, 2023 · 1 comment
Labels
A-crate-dependencies Area: [dependencies] of any kind A-git Area: anything dealing with git C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@ojacobson
Copy link

ojacobson commented Mar 15, 2023

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.

@ojacobson ojacobson added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Mar 15, 2023
@weihanglo weihanglo added A-git Area: anything dealing with git A-crate-dependencies Area: [dependencies] of any kind and removed A-git Area: anything dealing with git labels Mar 16, 2023
@tonyrewin
Copy link

This feature is really needed sometimes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-crate-dependencies Area: [dependencies] of any kind A-git Area: anything dealing with git C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

3 participants