-
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
Finish implementing cargo config
and related support
#2362
Comments
This commit adds a more principled system to rationalize what ends up being a configuration value versus an environment variable. This problem is solved by just saying that they're one and the same! Similar to Bundler, this commit supports overriding the `foo.bar` configuration value with the `CARGO_FOO_BAR` environment variable. Currently this is used as part of the `get_string` and `get_i64` methods on `Config`. This means, for example, that the following environment variables can now be used to configure Cargo: * CARGO_BUILD_JOBS * CARGO_HTTP_TIMEOUT * CARGO_HTTP_PROXY Currently it's not supported to encode a list in an environment variable, so for example `CARGO_PATHS` would not be read when reading the global `paths` configuration value. cc rust-lang#2362 cc rust-lang#2395 -- intended to close this in tandem with rust-lang#2397
This commit adds a more principled system to rationalize what ends up being a configuration value versus an environment variable. This problem is solved by just saying that they're one and the same! Similar to Bundler, this commit supports overriding the `foo.bar` configuration value with the `CARGO_FOO_BAR` environment variable. Currently this is used as part of the `get_string` and `get_i64` methods on `Config`. This means, for example, that the following environment variables can now be used to configure Cargo: * CARGO_BUILD_JOBS * CARGO_HTTP_TIMEOUT * CARGO_HTTP_PROXY Currently it's not supported to encode a list in an environment variable, so for example `CARGO_PATHS` would not be read when reading the global `paths` configuration value. cc #2362 cc #2395 -- intended to close this in tandem with #2397
So looks like this is blocked on the switch to |
I have put together a proposal for the design of @rust-lang/cargo FYI, if you have a chance to read and maybe give feedback. |
Thanks for typing this up @ehuss! My initial reaction was that I was wondering if we could do something Otherwise I thought your specification looked great. I like the multiple output options which should be easy enough for us to implement and should help make it a relatively powerful tool even right-out-the-gate. The other thought I had reading it was towards the end about alternative ways of configuring things, e.g. |
8494: CARGO: Retrieve config information r=vlad20012 a=avrong Adds the ability to get config properties using `cargo config get` subcommand tracked in rust-lang/cargo#2362. It can be improved in the future as rust-lang/cargo#9301 features will be implemented. Currently, it retrieves the config values of a specified path and parses them into a tree. Methods like `getBuildTarget` and `getEnvParams` return specific structured data Co-authored-by: vlad20012 <[email protected]>
Configuration in Cargo initially had a relatively grand vision, but much of it was unfortunately never implemented. This issue should help track finishing this support as well as explaining what it is intended to be!
A
cargo config
subcommandIt was initially intended to have a
cargo config
subcommand alagit config
orbundle config
. Configuration values could be read/written through this interface to the various locations on the system as need be.An example of this would be Bundler's
bundle config
command.The major blocker for this is being able to read a TOML file, modify some aspects of it, and then write it back to the filesystem. This should crucially preserve aspects such as comments, formatting, etc. Today we cannot do this.
Environment variables for configuration
Right now we've got a smattering of environment variables, but it's somewhat inconsistent in terms of what's an environment variables, what's a command line option, and what's a configuration option.
I believe it was originally intended that environment variables and configuration options should be one-and-the-same. All configuration options should have a mapping to an environment variable which provides the ability to read/write that field. For example Bundler has this as well.
The text was updated successfully, but these errors were encountered: