Skip to content

Commit

Permalink
docs: Clarify specifying deps, PR feedback 2
Browse files Browse the repository at this point in the history
  • Loading branch information
rimutaka committed Mar 5, 2024
1 parent 56e46a0 commit 35c1c53
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/doc/src/reference/specifying-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 224,17 @@ Other git hosts may provide something equivalent under a different naming scheme

```toml
# .git suffix can be omitted if the host accepts such URLs - both examples work the same
regex = { git = "https://github.com/rust-lang/regex"}
regex = { git = "https://github.com/rust-lang/regex.git"}
regex = { git = "https://github.com/rust-lang/regex" }
regex = { git = "https://github.com/rust-lang/regex.git" }

# a commit with a particular tag
regex = { git = "https://github.com/rust-lang/regex", tag = "1.10.3" }
regex = { git = "https://github.com/rust-lang/regex.git", tag = "1.10.3" }

# a commit by its SHA1 hash
regex = { git = "https://github.com/rust-lang/regex", rev = "0c0990399270277832fbb5b91a1fa118e6f63dba" }
regex = { git = "https://github.com/rust-lang/regex.git", rev = "0c0990399270277832fbb5b91a1fa118e6f63dba" }

# HEAD commit of PR 493
regex = { git = "https://github.com/rust-lang/regex", rev = "refs/pull/493/head" }
regex = { git = "https://github.com/rust-lang/regex.git", rev = "refs/pull/493/head" }

# INVALID EXAMPLES

Expand Down Expand Up @@ -262,7 262,7 @@ is compatible with `version = "1.10.3"`:

```toml
[dependencies]
regex = { version = "1.10.3", git = "https://github.com/rust-lang/regex", branch = "next" }
regex = { version = "1.10.3", git = "https://github.com/rust-lang/regex.git", branch = "next" }
```

`version`, `git`, and `path` keys are considered separate locations for resolving the dependency.
Expand Down Expand Up @@ -310,29 310,29 @@ all of its dependencies.

The local paths must point to the exact folder with the dependency's `Cargo.toml`.
Unlike with `git` dependencies, Cargo does not traverse local paths.
For example, if `cpp` and `cpp_common` are members of a locally cloned `rust-cpp` repo,
they have to be referred to by the full path:
For example, if `regex-lite` and `regex-syntax` are members of a
locally cloned `rust-lang/regex` repo, they have to be referred to by the full path:

```toml
# git key accepts the repo root URL and Cargo traverses the tree to find the crate
[dependencies]
cpp = { git = "https://github.com/mystor/rust-cpp" }
cpp_common = { git = "https://github.com/mystor/rust-cpp" }
regex-lite = { git = "https://github.com/rust-lang/regex.git" }
regex-syntax = { git = "https://github.com/rust-lang/regex.git" }

# path key requires the member name to be included in the local path
[dependencies]
cpp = { path = "../rust-cpp/cpp" }
cpp_common = { path = "../rust-cpp/cpp_common" }
regex-lite = { path = "../regex/regex-lite" }
regex-syntax = { path = "../regex/regex-syntax" }
```

### Local paths in published crates

Crates that use dependencies specified with only a path are not
permitted on [crates.io].

If we wanted to publish our `hello_world` crate, we
would need to publish a version of `hello_utils` to [crates.io]
as a separate crate and specify its version in the dependencies line of `hello_world`:
If we wanted to publish our `hello_world` crate,
we would need to publish a version of `hello_utils` to [crates.io] as a separate crate
and specify its version in the dependencies line of `hello_world`:

```toml
[dependencies]
Expand Down

0 comments on commit 35c1c53

Please sign in to comment.