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

Cannot easily use git dependencies that contain Cargo.toml files in subdirectories #6822

Closed
jdm opened this issue Apr 4, 2019 · 2 comments
Closed
Labels
A-git Area: anything dealing with git C-bug Category: bug

Comments

@jdm
Copy link

jdm commented Apr 4, 2019

Problem
Using a git dependency from a repository that contains multiple Cargo.toml files is complicated. If any of these files are invalid (such as files that are used as input for tests), or the result of complicated vendoring situations like Gecko, Cargo tries to make sense of them even if they will not actually contribute anything to the build. Using this same dependency as a path or published package works fine since only the appropriate package's Cargo.toml is read, but the git dependency is recursively walked for all Cargo.toml files that exist.

Steps

  1. Clone https://github.com/jdm/rust-mozjs/tree/smup66-cargo-problem
  2. Run cargo build

Possible Solution(s)
One easy way out - leave the current behaviour as default, but add an extra TOML property for git deps that makes it possible to specify a particular path inside the working tree which should be treated as the package root.

Notes

Output of cargo version:
cargo 1.35.0-nightly (63231f4 2019-03-27)

Without a solution to this problem, anyone using an unusual git dep must end up modifying its contents to remove the TOML files that Cargo can't understand. This is very frustrating, especially when the other dependency modes work just fine.

@jdm jdm added the C-bug Category: bug label Apr 4, 2019
@ehuss ehuss added the A-git Area: anything dealing with git label Jul 20, 2019
@sallaben
Copy link

@ehuss example use case: referencing the shaderc-sys crate if I fork this https://github.com/google/shaderc-rs

quark-zju added a commit to quark-zju/cargo that referenced this issue Feb 29, 2020
Commit 3d6de41 (rust-lang#3998) made cargo
ignore Cargo.toml files that are invalid TOML in a git source.
This change further ignores Cargo.toml files that are valid TOML but
cannot really be loaded.

This is potentially an alternative fix for rust-lang#6822.
bors added a commit that referenced this issue Mar 2, 2020
Ignore broken Cargo.toml in git sources

Commit 3d6de41 (#3998) made cargo
ignore Cargo.toml files that are invalid TOML in a git source.
This change further ignores Cargo.toml files that are valid TOML but
cannot really be loaded in a git source.

This is potentially an alternative fix for #6822.
@ehuss
Copy link
Contributor

ehuss commented Mar 23, 2020

This is more or less fixed by #7947. It would probably be good for some time in the future to have a way to restrict which directory Cargo looks at, but for now this should now work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-git Area: anything dealing with git C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants