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

Want env var specifying overriding config file #6728

Closed
ijackson opened this issue Mar 9, 2019 · 5 comments
Closed

Want env var specifying overriding config file #6728

ijackson opened this issue Mar 9, 2019 · 5 comments
Labels
A-configuration Area: cargo config files and env vars C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@ijackson
Copy link
Contributor

ijackson commented Mar 9, 2019

Problem

I have a situation where I have a .cargo/config which is nearly always right, and which I definitely very firmly want to be the default, but I need to be able to occasionally override it.

Because cargo simply searches up the directory tree there is no easy way to do this right now. I could override the config settings using env vars, but since some of the settings are tables that is no good.

Proposed solution

There should be an environment variable CARGO_CONFIG_INCLUDE which contains a :-separated list of TOML files. These should be read after all the .cargo/config files but processed before the command line, so that it overrides config files but is in turn overridden by the command line.

On Windows the list should be split (only) on ;. For the benefit of Windows, to make it possible to be compatible with both Unix and Windows, on Unix the list should be split on ; as well as :. As a result on Unix : and ; in filenames would be inexpressible; likewise ; in filenames on Windows. This is the traditional approach to path-like variables.

@ijackson ijackson added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Mar 9, 2019
@ijackson
Copy link
Contributor Author

ijackson commented Mar 9, 2019

This is related to #6699 "Proposal: Command-line config"

@ehuss
Copy link
Contributor

ehuss commented Mar 9, 2019

This is almost identical to what #6699 proposes, although it uses toml syntax. Would the toml syntax be particularly difficult to use?

@ehuss ehuss added the A-configuration Area: cargo config files and env vars label Sep 21, 2019
@zachlute
Copy link
Contributor

zachlute commented Feb 8, 2020

@ijackson Was just randomly looking through issues and noticed #6699, which accomplishes this same thing in a different manner, was closed. Is that enough for your needs, or do you still need an environment variable solution for some reason? It'd be nice to close this out if that solution meets your needs!

@epage
Copy link
Contributor

epage commented Oct 31, 2023

Cargo commands accept --config <path>. Is that sufficient for this use case?

@epage epage added the S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. label Oct 31, 2023
@weihanglo
Copy link
Member

I'm going to close due to inactivity. --config <config-path> should be able to cover most of the use cases in this proposal. Let us know if there is something overlooked.

@epage epage reopened this Mar 25, 2024
@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

5 participants