rustyhorde / vergen

Generate cargo instructions at compile time in build scripts for use with the env! or option_env! macros
Apache License 2.0
378 stars 56 forks source link

VERGEN_RUSTC_SEMVER and VERGEN_BUILD_TIMESTAMP are missing #253

Closed williamdes closed 8 months ago

williamdes commented 11 months ago
error: environment variable `VERGEN_RUSTC_SEMVER` not defined
  --> src/routes.rs:64:24
   |
64 |     let rustc_semver = env!("VERGEN_RUSTC_SEMVER");
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

error: environment variable `VERGEN_BUILD_TIMESTAMP` not defined
  --> src/routes.rs:65:27
   |
65 |     let build_timestamp = env!("VERGEN_BUILD_TIMESTAMP");
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I am currently using

[build-dependencies]
vergen = { version = "8.2.4", default-features = false, features = ["build", "rustc"] }
CraZySacX commented 10 months ago

Need more information (rustc -Vv and cargo -Vv output would be a good start). Both variables are set (and compile) in my environments with your same configuration: vergen-cl-build-rustc

williamdes commented 9 months ago

Sorry for the delay

$ rustc -Vv
rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-unknown-linux-gnu
release: 1.73.0
LLVM version: 17.0.2
$ cargo -Vv
cargo 1.73.0 (9c4383fb5 2023-08-26)
release: 1.73.0
commit-hash: 9c4383fb55986096b414d98125421ab87b5fd642
commit-date: 2023-08-26
host: x86_64-unknown-linux-gnu
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.2.1-DEV (sys:0.4.65+curl-8.2.1 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Debian 12 (bookworm) [64-bit]
dayn9t commented 9 months ago
error: environment variable `VERGEN_BUILD_DATE` not defined at compile time
[build-dependencies]
vergen = { version = "*", features = ["build", "git", "cargo"] }
➜  ~ rustc -Vv
rustc 1.76.0-nightly (a1a37735c 2023-11-23)
binary: rustc
commit-hash: a1a37735cbc3db359d0b24ba9085c9fcbe1bc274
commit-date: 2023-11-23
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5
➜  ~ cargo -Vv
cargo 1.76.0-nightly (71cd3a926 2023-11-20)
release: 1.76.0-nightly
commit-hash: 71cd3a926f0cf41eeaf9f2a7f2194b2aff85b0f6
commit-date: 2023-11-20
host: x86_64-unknown-linux-gnu
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0-DEV (sys:0.4.68+curl-8.4.0 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Ubuntu 22.04 (jammy) [64-bit]

Environment variables CARGO_PKG_* work well.

JDeeth commented 8 months ago

Are you using EmitBuilder::builder().emit(), without anything between .builder() and .emit()?

There needs to be additional methods in there to select which environment variables to emit - https://docs.rs/vergen/8.2.6/vergen/struct.EmitBuilder.html

e.g.

EmitBuilder::builder()
    .all_rustc()
    .all_build()
    .emit()

or

EmitBuilder::builder()
    .rustc_semver()
    .build_timestamp()
    .emit()

This caught me out too (#282)

CraZySacX commented 8 months ago

This should be resolved with the 8.2.8 release. Please feel free to re-open if it isn't