-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
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.