Skip to content

Allow specifying pull request deps using the github PR link #15001

Open
@joshka

Description

@joshka

Problem

From time to time I need to submit a PR to a lib and then want to rely on that PR in my local code.
Every time I do this I have to search the docs to work out the specific syntax that I need.
It would be nice if I could just use GitHub's PR syntax for this (or at the very least the error message should point me in the right direction)

Proposed Solution

Option 1. Support this as-is:

[dependencies]
foo = { version = "1", git = "https://github.com/bar/foo/pull/123" }

I understand why this might not be ideal even if it's the most developer friendly fix for this. So alternatively:

Option 2. Provide a better error message for this scenario that provides the right syntax:

Current error message:

    Updating git repository `https://github.com/bar/foo/pull/123`
warning: spurious network error (3 tries remaining): unexpected http status code: 404; class=Http (34)
warning: spurious network error (2 tries remaining): unexpected http status code: 404; class=Http (34)
warning: spurious network error (1 tries remaining): unexpected http status code: 404; class=Http (34)
error: failed to get `foo` as a dependency of package `some-package v0.1.0 (/Users/joshka/local/some-package)`

Caused by:
  failed to load source for dependency `some-package`

Caused by:
  Unable to update https://github.com/bar/foo/pull/123

Caused by:
  failed to fetch into: /Users/joshka/.cargo/git/db/161-9e1cf949600a4ac3

Caused by:
  network failure seems to have happened
  if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  unexpected http status code: 404; class=Http (34)

Expected error message (something like):

The git dependency for `foo` points at the pull request url. Fix this by changing to `foo = { version = "1" git = "https://github.com/bar/foo" rev = "refs/pull/123/head"

Notes

I understand that there's other code forges than GitHub, but it's reasonable to fix the 99% case even when other cases are not fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-crate-dependenciesArea: [dependencies] of any kindA-diagnosticsArea: Error and warning messages generated by Cargo itself.A-gitArea: anything dealing with gitA-patchArea: [patch] table overrideC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions