Skip to content
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

Add support for managing "[patch.crates-io]" #274

Open
rvolgers opened this issue Feb 17, 2019 · 6 comments
Open

Add support for managing "[patch.crates-io]" #274

rvolgers opened this issue Feb 17, 2019 · 6 comments

Comments

@rvolgers
Copy link

rvolgers commented Feb 17, 2019

The proposal is to allow cargo-edit to manage this Cargo feature:

https://rust-lang-nursery.github.io/edition-guide/rust-2018/cargo-and-crates-io/replacing-dependencies-with-patch.html

The command cargo add-patch frob --path=~/frob would add a line to a patch section in Cargo.toml:

[patch.crates-io]
frob = { path = "/home/user/frob" }

The cargo rm-patch frob would remove this line.

Some complexities / open questions:

  • The section may have to be created when adding a patch.
  • The section should probably be deleted when removing the last line of content.
  • The section name contains the repository name (which is usually, but not always, crates-io). This could be specified using an extra argument that defaults to the default repository, but the naming of that argument is a bit tricky since you are potentially dealing with two repository names (the original one and the override). We could also in theory try to auto-detect the repository name by searching the dependency graph for the named crate, but (again, in theory) I think it might be possible to find two crates with the same name in the dependency graph from different repositories?

Edit: Made various changes after thinking about it some more.

@jhpratt
Copy link

jhpratt commented Mar 27, 2020

@killercup Would a PR be accepted that implements this to an extent?

@ordian
Copy link
Collaborator

ordian commented Mar 27, 2020

This functionality seems useful, but I'm not convinced about adding new commands for that and not e.g. using --patch-crates-io flag. A PR would be accepted, but we need to agree on how will it look like first.

@killercup
Copy link
Owner

Agreed. It's a good feature to have, especially if we can make it work smoothly (e.g. by checking that the path contains the expected crate and other things you'd not get by editing the file by hand).

@eopb
Copy link
Contributor

eopb commented Aug 26, 2023

I've started working on a separate crate that dose this called cargo override.

I'd like to spend some time experimenting with the interface in a separate repo. Long term it'd be great to integrate it into cargo-edit.

I'll share it here as soon as I have an MVP.

@epage
Copy link
Collaborator

epage commented Aug 28, 2023

Some related cargo issues with additional ideas and potential existing commands

@eopb
Copy link
Contributor

eopb commented Sep 2, 2024

I've released a working version of cargo override 🎉

https://github.com/eopb/cargo-override

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants