Skip to content

Cargo toml env vars are not set on build scripts at runtime #3625

@dzbarsky

Description

@dzbarsky

We use the cargo_toml_env_vars rule to extract the CARGO_* env vars from the Cargo.toml and pass them to rustc_env_files for both the crate and it's corresponding build script, but we don't use those env var files to set the runtime env vars for the build script. We set some of them in the rule, but are still missing some like CARGO_PKG_AUTHORS.

This manifests as the built crate failing to find the env vars it expects at runtime when used as a build dep, and thus crates using it failing to build, such as rav1e as a result.

It's not quite clear to me the best way to fix this - while cargo_build_script_runner seems to support loading an env file, it's not obvious that propagating rustc_env_files is semantically correct. Perhaps the cargo_build_script macro should have taken a cargo_env_vars_file attribute which would more cleanly imply it should apply at both compile time and runtime. @UebelAndre @illicitonion wdyt?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions