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

Cargo config reference should more clearly explain mapping complex keys to environment variable names #7610

Closed
b-spencer opened this issue Nov 19, 2019 · 0 comments · Fixed by #7650
Assignees
Labels
A-documenting-cargo-itself Area: Cargo's documentation A-environment-variables Area: environment variables C-bug Category: bug

Comments

@b-spencer
Copy link

Problem

The cargo config reference page says this:

For each configuration key above of the form foo.bar the environment variable CARGO_FOO_BAR can also be used to define the value. For example the build.jobs key can also be defined by CARGO_BUILD_JOBS.

This is correct, and the simple example is useful. However, the transformation of non-alphanumeric characters is not documented and it isn't obvious how to map a more complex config parameter such as:

[target.aarch64-linux-android]
linker = "/some/linker"

to an environment variable. I tried many combinations unsuccessfully until I eventually found an old issue asking about the same problem:

I tried:

LD
LINKER
CARGO_BUILD_LINKER
CARGO_TARGET_i686-pc-windows-gnu_LINKER

But none had the same effect as a config file containing:

[target.i686-pc-windows-gnu]
linker = "c:/Rtools/mingw_32/bin/gcc"

Possible Solution(s)

I suggest expanding on the docs to give a complex example such as:

Replace any characters . or - in key names with _ and upper case the result. For example,

[target.aarch64-linux-android]
linker = "/some/linker"

can be set with the environment variable CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=/some/linker.

I hope this helps the next person who stumbles across the need to set these values via the environment.

@b-spencer b-spencer added the C-bug Category: bug label Nov 19, 2019
@ehuss ehuss added A-documenting-cargo-itself Area: Cargo's documentation A-environment-variables Area: environment variables labels Nov 19, 2019
@ehuss ehuss self-assigned this Nov 19, 2019
@bors bors closed this as completed in 6b4dd23 Dec 3, 2019
@bors bors closed this as completed in #7650 Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation A-environment-variables Area: environment variables C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants