-
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
Tracking issue for config-include #7723
Comments
Some additional wishes (from #9306):
|
Some quick thoughts on this: Restrictions on the path. What's the motivation for restricting the paths? Cargo potentially having special files in Multiple includes. I think the ability to have multiple Include globs. I'm torn on allowing globs. They tend to cause headaches as much as it fixes them. One option might be to instead say that Cargo implicitly has a top-level include for each file in Missing files. I think we should initially have just Placeholders. This feels like something worth punting on until we see use in practice, and not something that should block |
|
Why must it produce no warnings?
I don't think this feature will help you with includes for
I think that's simply just not allowed by the TOML spec, though I could be wrong. At the very least it would require some custom de/serialization to handle duplicate keys. Your alternative proposal of introducing table entries in the
I personally strongly prefer explicit syntax ( |
Because the setup is not in git (it is local). When other people clone the project they will either be spammed by warnings about non-existing files, or they have to create them manually. |
Try to push this toward stabilization a bit. Here lists concerns that I feel like they could be a
|
This is a wrong assumption. People can use config-include for local configuration (e.g. for
This means, a simple |
Then I will argue why the crate author added an One benefit I can see is that it forces people to put their config files in a "dedicated" path the crate author wants. In that case, shouldn't it be better as a hard error? But anyway, since we consider config files as a kind of local environment, I agree with you that it may also make sense starting from a warning. |
It will happen when people use include files for optional local setup. How will you handle it else, when
IMO such configuration fragments should be optional and do not cause a dirty vcs tree. E.g. place it in
to Btw, glob expansion would solve many problems; either explicitly like
or by looking automatically below
no; there should not be a warning. Missing files should be ignored silently. |
Thanks for the feedback. The workflow of yours looks valid, though I don't agree on completely ignoring missing files. Downgrading to a warning seems fine to me. Ignoring is not. If it were a silent ignore, how long would it take for people to figure out there is a typo in their That being said, one future work of Personally I lean toward not adding new feature at this time, they can be implemented afterward in a compatible way. |
Make it explicit whether file is required or optional. It was discussed some comments above:
I fear, that optional, local customization will never be implemented when some basic, half-baked include mechanism exists. |
@ensc We might be open to adding a feature for optional config files, such as |
@joshtriplett ok; by looking at the speed of implementing new features, this means that cargo will probably never support optional configuration files :( |
The Cargo team discussed this on Tuesday. We are going to stabilize the feature as is. We notice that there are some possible extensions, however, we believe they could be added later after the stabilization. The only last minute stuff added was #12298, which puts a restriction on config include path to allow only Let's do a final check before the stabilization PR @rfcbot fcp merge |
Team member @weihanglo has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns: Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
or cargo vendor setup |
I'm also concerned about the lack of end-users driving this. Use cases from end-users help us make sure we are delivery features in the way needed rather than tying us down with compatibility with something no one uses. Looking at #6699 and #7649, this seems more driven as a "could this potentially be useful" rather than someone saying "I have problem X that I need solved". #9306 is linked to in this thread but that requires further extensions (glob or optional config support). If this were a personal project of mine, like clap, I'd either work towards #9306 or remove this feature. |
Thanks for the feedback. There are some details I can share with. People want to have some controls over configuration file loading for a long while. This is just one of those possible solutions. ##9769 is a collection of them. Some configs in One workaround is to inject all the generated config into If we have
I was worried about this but forgot to write it out. I am more worried that |
The concept of If you're concerned with satisfying end-user cases, all of our end-user cases rely on optionality, though it is something we've had to hack in, even with the addition of |
For a large monorepo that lots of people collaborate on, it is easier to educate people to put their project-local config.toml in the same location, say,
A project that already checked [profile.test]
debug = false to speed up the test build and reduce memory usage in CI pipeline. For local development, user might want to turn it own at per-project-level, but without Granted, we have |
I have a usecase for something in this area now, but it requires the support for "optional includes". We have a shared workspace config committed into the repository for the xtask pattern, but we also commonly want to be able to apply patches while testing changes across multiple repositories: # .cargo/config.toml
include = "config.local.toml"
[alias]
xtask = "run --package xtask --bin xtask --" # Cargo.toml
...
# If you want to get `foobar` from your local machine then create a `.cargo/config.local.toml` in this directory with:
#
# [patch."ssh://[email protected]/foobar/foobar.git"]
# foobar.path = "../foobar"
#
# (adapting the path as needed relative to this directory) Having to edit a version-controlled file and remember to not commit it (or keep reverting and reapplying the changes when using a VCS like Jujutsu that doesn't allow not committing) is painful. Re-reading the docs now I also notice that the precedence is backwards for this sort of usecase, to get the correct precedence (local config can override shared config) requires committing two config files into the repo: # .cargo/config.toml
include = [ "config.shared.toml", "config.local.toml" ] # .cargo/config.shared.toml
[alias]
xtask = "run --package xtask --bin xtask --" |
I just hit a use case where this feature will be very useful. I'm using pyo3 in my project and it frequently recompiles the whole project even for small change. This happens because of the difference in Python path in my cli and vscode rust analyzer. Running a cargo command in CLI invalidates the build artifacts from rust analyzer The solution1 is to make the rust analyzer and CLI use the same python path by setting the
I hope this gets merged soon 😄 Footnotes |
A workaround is to have an intermediate directory containing additional |
For tock, it would be helpful for us to be able to include different config files (and hence different compiler/linker flags) for different hardware platforms and different architectures. For example, there are certain flags we only want to include on RISC-V platforms, and we would benefit from keeping those in one (optional) cargo config file rather than copying them for each individual platform (making maintenance more difficult). Right now we are accomplishing this using |
Also, we (tock) generally use nightly, so we can use the unstable feature, but it doesn't seem to work when enabled in a config file. For example:
My |
…g, r=weihanglo Allow enabling `config-include` feature in config ### What does this PR try to resolve? Prior to this change, it is not possible to enable the unstable `config-include` flag from within a config file itself. This is due to the fact that, while cargo does reload configuration files if this flag is set, it does not parse the top-level configuration file's unstable flags before checking whether this flag is present. This commit forces cargo to load unstable features before this check, and if the flag is present, re-loads configuration files with `config-include` enabled. Addresses #7723 (comment). ### How should we test and review this PR? This PR adds a testcase for this behavior to cargo's testsuite. In general, it can be replicated with a config similar to that in the testcase, or as illustrated in #7723 (comment). ### Additional information ~I'm not sure whether this is the right(TM) fix, or whether the second `self.load_unstable_flags_from_config()?;` at the bottom of `configure()` would still be required. I have a feeling it might not be, as `reload_rooted_at` also calls out to `load_unstable_flags_from_config`, to collect flags from any newly included configs. If that is not called, no other file was loaded, and thus there should not be a need to re-load unstable flags.~ Resolved: #14196 (comment)
I can confirm that #14196 fixed my issue. The |
@bradjc Would you mind elaborating this more, and sharing the Makefile? |
I think this open PR is the most clear explanation before and after: https://github.com/tock/tock/pull/4075/files We optionally add |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@rfcbot concern syntax I would like to consider changing the syntax before stabilizing to make it easier to possibly extend in the future. Currently we have: include = "path/to/file.toml"
# or
include = ["array/of/files.toml", "two.toml"] However, if we intend to add other properties like I don't know exactly what syntax we should use. Above it was suggested to use a table, like: include = { path = "some.toml", optional = true }
# or
include = { paths = ["a.toml", "b.toml"], optional = true } Another option is to make it an array of tables, which would allow specifying settings for each file: [[include]]
path = "a.toml"
optional = true
[[include]]
path = "b.toml"
optional = false I also don't know exactly what it would look like if we want to add conditions (or even what conditions we might have). This feature was originally modeled after gitconfig, which uses a conditional syntax like:
Also note that git silently ignores missing includes, whereas cargo will error. I'm not sure which default is the right one. |
@rfcbot concern syntax |
Implementation: #7649Nightly: `include` config key
Original proposal: #6699
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#config-include
Issues: Z-config-include
Summary
Adds the
include
config key to include other config files.Unresolved issues
.cargo/config-*
in case we want to safely use other filenames in.cargo/
for other purposes. However, it seems like an unnatural restriction. Another restriction is that it should maybe end in.toml
?FCP
The text was updated successfully, but these errors were encountered: