Skip to content

Cargo doesn't uniformly read configuration from env vars #5416

Open

Description

Most configuration read through cargo uses helpers like Config::get_string which automatically read env vars, but configuration reading portions of Cargo that go through Config::get_table do not read environment variables. The return value here is a HashMap which doesn't proxy reads to an environment variable.

This affects, for example, source replacement. Source replacement is not configurable through environment variables (a bug) because of its use of get_table.

We should tackle this via one of two routes:

  • First, remove get_table entirely. Just don't expose the ability to read a table and force all configuration reads to go through get_string and friends. This may or may not be uniformly possible as IIRC there's portions of Cargo that rely on iter which is a bit of a bummer.
  • Second, change get_table to return a wrapper rather than a HashMap. Reads of the HashMap would "do the right thing" with environment variables. Again though it's not clear how such a wrapper would implement iter as well...

In any case, some questions to still work through here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-configurationArea: cargo config files and env varsA-environment-variablesArea: environment variablesC-bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Z-advanced-envNightly: advanced-env

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions