Describe the bug
At start of Rust crate build, developers can emit various directives in build.rs that then impact the rest of the build.
It seems that cargo handling of these directives differs from the buildRustCrate handling we have when the values contain spaces.
Steps To Reproduce
Create build.rs like below:
fn main() {
println!("cargo:rustc-env=SHOULD_BE_THREE_WORDS=first second third")
}
Simple src/main.rs
fn main() {
let should_be_three_words = env!("SHOULD_BE_THREE_WORDS");
println!("Expecting three words, got: {}", should_be_three_words);
}
Cargo.toml for completeness
[package]
name = "nix-rustc-env-escape-repro"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
Create a nix derivation for a create. I'm using crate2nix but you can use whatever, as long as it goes via buildRustCrate in the end.
$ crate2nix -- generate -f ./Cargo.toml
Finally, run both via cargo and via buildRustCrate and see the difference.
[nix-develop]$ $(nix-build -I nixpkgs=/home/shana/programming/nixpkgs Cargo.nix -A rootCrate.build --no-out-link)/bin/nix-rustc-env-escape-repro
Expecting three words, got: first
[nix-develop]$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/nix-rustc-env-escape-repro`
Expecting three words, got: first second third
Expected behavior
The nixpkgs builder should have the same semantics as the cargo one.
Notify maintainers
Unsure.
Metadata
nixpkgs 067c3ad
anything else should be irrelevant here
Describe the bug
At start of Rust crate build, developers can emit various directives in
build.rsthat then impact the rest of the build.It seems that
cargohandling of these directives differs from thebuildRustCratehandling we have when the values contain spaces.Steps To Reproduce
Create
build.rslike below:Simple
src/main.rsCargo.tomlfor completenessCreate a nix derivation for a create. I'm using
crate2nixbut you can use whatever, as long as it goes viabuildRustCratein the end.$ crate2nix -- generate -f ./Cargo.tomlFinally, run both via cargo and via
buildRustCrateand see the difference.Expected behavior
The nixpkgs builder should have the same semantics as the cargo one.
Notify maintainers
Unsure.
Metadata
nixpkgs 067c3ad
anything else should be irrelevant here