-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Variable substitution in cargo.toml #4221
Comments
I'm running in to a similar issue. I have a workspace with 7 sub configs. There a quite a bit of duplication in these files since crates share the same meta info, version, and some external and internal dependencies. Some of the duplication could be solved by using substitution variables or pushing up some of the values to the top level. It would certainly make packaging and publishing easier if I could just bump a number up in one file instead of doing it over many. |
hey @stepancheg thanks for filing this! in order to proceed with this, the team would need to decide whether this is a feature we would want to accept. @carols10cents is gonna throw this on the team agenda to discuss it! we'll follow up after that. |
We discussed this in the cargo meeting, and we agree that it's is annoying to have to update the version number in multiple places. However, we don't think supporting variables in Cargo.toml is a great solution to this problem-- we'd rather work on enhancing workspaces to support using one version of a crate across the workspace. Additionally, if you do want to have variables interpolated into your Cargo.toml, it's possible to do this with a tool external to cargo that would be run before building. So we don't think adding variable interpolation is something cargo should support. Thank you for the issue though! 🌞 |
Just wanted to add a +1 to this old thread, since I'm hitting the same issue - when you have two crates that need the same version, you have to remember to keep them in sync. Java's Gradle has the |
The workaround I use now is to tag a version with a unique comment like this in all my crates:
Then it's relatively easy to search and replace on |
That's a tad hacky. Do not repeat yourself is a principle for a reason. |
While working with Cargo, editing version numbers is a bit annoying.
For example, I have a repository with two crates:
When I incrementing version number, I need to edit version several times, which is as i said, annoying, because I constantly forget to update one of several version fields.
What think could solve this problem is something like substitution variables declared in
[workspace]
section. E. g.The text was updated successfully, but these errors were encountered: