Skip to content

Clobbering of environment variables during recursive invocations of cargo #15350

Open
@ratmice

Description

@ratmice

Problem

sometimes it would be convenient to do things like cargo run within .cargo/config.toml

[target.wasm32-wasip2]
runner = "cargo run -p my_runner"

So that you can avoid a separate install process for the test runner.

The caveat of this is that cargo run overwrites a bunch of environment variables that initially set by the cargo process that invoked the runner.

Proposed Solution

For cases such as this it would be nice to have an cargo run --env-var-prefix foo_ -p my_runner
this would then set variables like foo_OUT_DIR etc.

Perhaps a better way would be to just have a rarely used Cargo.toml field to specify an env var prefix, so
my_runner/Cargo.toml can use that, it would then be expected that my_runner/build.rs take part in
understanding that this crate always uses that env prefix. That seems more acceptable to me anyways.

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-configurationArea: cargo config files and env varsA-cross-compilingArea: using --target flag for other platformsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-runS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions