-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Closed
Labels
0.kind: bugSomething is brokenSomething is broken
Description
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.tomlFinally, 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 thirdExpected 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
0.kind: bugSomething is brokenSomething is broken