Skip to content

Patch section in a separate file #10832

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

Closed
wyfo opened this issue Jul 7, 2022 · 4 comments
Closed

Patch section in a separate file #10832

wyfo opened this issue Jul 7, 2022 · 4 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@wyfo
Copy link

wyfo commented Jul 7, 2022

Problem

I would like to use patch section to do local development, patching a dependency to use a path. However I don't want to pollute Cargo.toml with local/temporary stuff, because Cargo.toml is versioned.

Proposed Solution

Allow for a new file, named Cargo-patch.toml (or whatever name better suited). When the file is present, its content is added to the patch section of Cargo.toml, overriding items present in both files.

This feature could be turned off (with an environment variable for example) to use unpatched Cargo.toml with tools like pre-commit.

Notes

No response

@wyfo wyfo added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jul 7, 2022
@ehuss
Copy link
Contributor

ehuss commented Jul 7, 2022

Patches can also be specified in a config file. Does that work for you?

@wyfo
Copy link
Author

wyfo commented Jul 7, 2022

Oh indeed, it's perfect. Sorry for the noise ...

@wyfo wyfo closed this as completed Jul 7, 2022
@wyfo
Copy link
Author

wyfo commented Jul 7, 2022

By the way, maybe the documentation part about Overriding Dependencies is a little bit out of date, because .cargo/config.toml is only mentioned for paths overrides.
(In my case, I wanted to patch git dependencies, so paths overrides would not have worked)

Should I open a new issue about documentation update?

@ehuss
Copy link
Contributor

ehuss commented Jul 9, 2022

Nah, I just opened a quick PR at #10836 to include it in the docs. Thanks for the suggestion! I completely missed that we didn't update that chapter. (Config support was just recently added.)

bors added a commit that referenced this issue Jul 9, 2022
Mention `[patch]` config in "Overriding Dependencies"

The "Overriding Dependencies" chapter is the primary documentation for the `[patch]` table, but it does not mention that `[patch]` also works in config files. This adds a note to mention this option.

cc #10832 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

2 participants