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

Give more examples of turning .cargo/config keys into env vars #3985

Closed
shahn opened this issue May 2, 2017 · 7 comments
Closed

Give more examples of turning .cargo/config keys into env vars #3985

shahn opened this issue May 2, 2017 · 7 comments
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@shahn
Copy link

shahn commented May 2, 2017

I'm using cargo in an autoconf-managed build system. I want to auto-generate a part of the .cargo/config file, because Cargo doesn't seem to expose env variables for the vendored sources config options, but where the vendored sources live should be overwritable by the user during ./configure. It seems cargo really wants to be run inside the source tree, but config.status places the generated .cargo/config into the build dir. Copying the entire rust tree of the project from the source dir into the build dir could be a workaround, but instead it'd be neat if cargo allowed to just specify a different location for its config file.

@alexcrichton
Copy link
Member

Note that it's a bug in Cargo if Cargo doesn't read .cargo/config values from the environment, so I think that may be the best fix here?

@shahn
Copy link
Author

shahn commented May 2, 2017

Perhaps I misunderstand, but what would the env variables even be for something like [source.vendored-sourced] where the vendored-sources seems to be a user-defined string?

@alexcrichton
Copy link
Member

Oh in general we just have a standard mechanism for defining config values as environment variables

@shahn
Copy link
Author

shahn commented May 3, 2017

that doesn't explain at all how to set that, or at least I don't understand it. It says: "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 doesn't explain how to put this:

[source.vendored-sources]
directory = "foo"

into env variables. Also, how can I unset something via env variable that's given in a configuration file? Happy to improve the documentation once I understand that :)

@alexcrichton
Copy link
Member

Oh that would in theory be CARGO_SOURCE_VENDORED_SOURCES_DIRECTORY=foo. Unfortunately there's no way to unset what's in a config file, although I believe the environment takes precedence.

PRs are of course always welcome to improve the docs!

@carols10cents carols10cents changed the title Specify config file location via environment Give more examples of turning .cargo/config keys into env vars Oct 2, 2017
@carols10cents carols10cents added A-documenting-cargo-itself Area: Cargo's documentation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` labels Oct 2, 2017
@dylanede
Copy link

@alexcrichton It doesn't look like setting environment variables to set source properties like that is supported, and the relevant source code is just looking up "sources" from a hash map, without checking the environment variables. I'll raise a bug for this.

@ehuss
Copy link
Contributor

ehuss commented Dec 19, 2019

There is now a lot more information about setting environment variables via #7650. The [source] table not supporting env vars is tracked via #5416.

@ehuss ehuss closed this as completed Dec 19, 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 C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

5 participants