Skip to content

Want env var specifying overriding config file #6728

@ijackson

Description

@ijackson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-configurationArea: cargo config files and env varsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions