cargo: Patching dependencies does not work if it's for the same location but a different branch

E.g.

[patch.'https://github.com/sdroege/gobject-subclass']
gobject-subclass = { git = 'https://github.com/sdroege/gobject-subclass', branch = 'refactoring' }

This gives

error: failed to resolve patches for `https://github.com/sdroege/gobject-subclass`

Caused by:
  patch for `gobject-subclass` in `https://github.com/sdroege/gobject-subclass` points to the same source, but patches must point to different sources

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 58
  • Comments: 21 (8 by maintainers)

Commits related to this issue

Most upvoted comments

For GitHub repositories, one can work around this by [patch]ing https://github.com/user/repo to https://github.com/user/repo.git (or the other way around).

Nice workaround hack! Further ways to change the URL string include adding / to the url like https://github.com////user///repo . This method scales to unlimited amounts of different urls for the same repo.

For GitHub repositories, one can work around this by [patch]ing https://github.com/user/repo to https://github.com/user/repo.git (or the other way around).

Nice workaround hack! Further ways to change the URL string include adding / to the url like https://github.com////user///repo . This method scales to unlimited amounts of different urls for the same repo.

These workarounds no longer do it for me (using cargo 1.52.0)–perhaps Cargo is now normalizing repo names?

If anyone is having trouble with overriding SSH URLs, and can’t use HTTPS for whatever reason (eg. private git repo) I found another workaround is to add the port number to the URL, like ssh://git@github.com:22/<org>/<repo>.git

Have you tried this:

ethers-rs = { git = "https://github.com/gakonst////ethers-rs.git", branch = "test" }

The canonicalization code only strips trailing / and .git. For extra / inside the URL, it doesn’t do anything.

For GitHub repositories, one can work around this by [patch]ing https://github.com/user/repo to https://github.com/user/repo.git (or the other way around).

This worked for me (www and .git) :

[patch.'https://github.com/foo/bar']
baz = { git = "https://www.github.com/foo/bar.git", branch = "test" }