Closed dmitrii-ubskii closed 8 months ago
See https://github.com/cross-rs/cross/issues/864#issuecomment-1166574381
Can't reproduce:
$ cargo run
Compiling env-test v0.1.0 (/Users/dmitriiubskii/workspace/misc/env-test)
Finished dev [unoptimized + debuginfo] target(s) in 0.44s
Running `target/debug/env-test`
env::var_os("CARGO")=Some("/Users/dmitriiubskii/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo")
env::var("CARGO")=Ok("/Users/dmitriiubskii/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo")
$ CARGO=~/Downloads/cargo cargo run
Compiling env-test v0.1.0 (/Users/dmitriiubskii/workspace/misc/env-test)
Finished dev [unoptimized + debuginfo] target(s) in 0.50s
Running `target/debug/env-test`
env::var_os("CARGO")=Some("/Users/dmitriiubskii/Downloads/cargo")
env::var("CARGO")=Ok("/Users/dmitriiubskii/Downloads/cargo")
$ CARGO=cargo cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running `target/debug/env-test`
env::var_os("CARGO")=Some("/Users/dmitriiubskii/workspace/misc/env-test/cargo")
env::var("CARGO")=Ok("/Users/dmitriiubskii/workspace/misc/env-test/cargo")
Granted, running CARGO=cross cargo run
does print my ~/.rustup/...
cargo path, but that's because cross
isn't a valid path. The CARGO=cargo
example uses the cargo
file in the pwd.
If cargo is not present in
PATH
, zigbuild (when run directly) fails with "Failed to run cargo build: No such file or directory (os error 2)", even ifCARGO
[1] is set correctly. This appears to be a bug in cargo-options [2], but since that is a tiny package, I'm also reporting it here. Cf. https://github.com/messense/cargo-options/issues/8[1] https://doc.rust-lang.org/cargo/reference/environment-variables.html [2] https://github.com/messense/cargo-options/blob/main/src/common.rs#L167