rust-lang / rust-lang/cargo

Walk `path` repository until dependency is found rather than requiring it to be at the repository root as done for `git`

Open
#13,360 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-crate-dependencies C-feature-request S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Problem

Currently, packages specified by git repositories will search the git project for sub-packages. The following will correctly find bevy_math

[dependencies]
bevy = { path = "/Users/jpedrick/Development/bevy", default-features = false }
bevy_math = { git = "https://github.com/bevyengine/bevy.git" }

However, with path specified packages this doesn't work:

[dependencies]
bevy = { path = "/Users/jpedrick/Development/bevy", default-features = true }
bevy_math = { path = "/Users/jpedrick/Development/bevy" }

Instead, bevy_math needs to be explicitly targeted with the path

[dependencies]
bevy_math = { path = "/Users/jpedrick/Development/bevy/crates/bevy_math/" }

I found this a bit confusing, as I expected crate imports with path to work the same as git.

Proposed Solution

The following would find the bevy_math package in /Users/jpedrick/Development/bevy/crates/bevy_math/ by searching for the Cargo.toml with package.name == "bevy_math"

[dependency]
bevy_math = { path = "/Users/jpedrick/Development/bevy" }
Notes

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by tracing Cargo's path-dependency resolution and comparing it with the existing git repository package search. Done means a path dependency can locate the requested package in a nested Cargo.toml, such as bevy_math under crates/bevy_math.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.