-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Walk path
repository until dependency is found rather than requiring it to be at the repository root as done for git
#13360
Comments
As this was a conscious choice (the Git Source is implemented as a wrapper around Path Source), I would very much want to understand why it was originally designed this way before making changes. One potential reason is that path dependencies are expected to be used more often and recursively walking can be a performance problem. For brainstorming purposes, as cargo is intended to be opinionated, I wonder if we could speed up that walking by enforcing good practices by (1) checking |
My guess is that the number of files in a Git repository is under control, while an arbitrary path might lead to an unbound walk through the filesystem. To support this feature, Cargo needs to address the duplicate packages issue (such as #10752), which hasn't really got resolved for git dependency and is poorly documented. #9624 is a relevant issue as well. |
Thanks @epage for the background here. It makes sense to me that there is a simple I think I'd be good with a few different solutions, in order of increasing consequences:
As a newer user, I found this error message confusing/unhelpful when moving from a
from the following dependency node in my [dependencies]
examples_common_2d = { path = "../examples_common_2d" }
bevy_math = { path = "/Users/jpedrick/Development/bevy", features = ["approx"] } Something like the following might be more user friendly:
[dependencies]
bevy_math = { path/git = ".../path/to/bevy", find_subpackage=true } OR: [dependencies]
bevy_math = { path/git = ".../path/to/bevy", subpackage_path="crates/bevy_math" } And then deprecate with warnings the current default search behavior for git.
When defining dependencies you could validate the import by requiring the full path in the dependency node name: [dependencies]
bevy::bevy_math = { path/git = ".../path/to/bevy" } Alternatively, a less opinionated option would be to have the root [subpackages]
bevy_math = "crates/bevy_math"
bevy_winit = "crates/bevy_winit" OR [package]
subpackage_root = "my_crates" |
@weihanglo seems to me walking the file tree or finding the wrong subpackage due to duplicate crate names could be completely avoided by having an opinionated structure or by requiring users to provide the subpackage mapping, whether in the source crate Cargo.toml or as an attribute on the dependency node.
|
I think this could be worthwhile to do so people have an improved experience until and if we decide to do any of the other steps btw the other steps remind me of some of the discussions around rust-lang/rfcs#3529. |
I agree |
Problem
Currently, packages specified by git repositories will search the git project for sub-packages. The following will correctly find
bevy_math
However, with path specified packages this doesn't work:
Instead,
bevy_math
needs to be explicitly targeted with thepath
I found this a bit confusing, as I expected crate imports with
path
to work the same asgit
.Proposed Solution
The following would find the
bevy_math
package in/Users/jpedrick/Development/bevy/crates/bevy_math/
by searching for theCargo.toml
withpackage.name == "bevy_math"
Notes
No response
The text was updated successfully, but these errors were encountered: