#cargo-build #build-script #env-var #build #instructions #cargo #build-time

build vergen-git2

Generate 'cargo:rustc-env' instructions via 'build.rs' for use in your code via the 'env!' macro

3 releases

1.0.0-beta.2 Feb 3, 2024
1.0.0-beta.1 Jan 30, 2024

#363 in Build Utils

Download history 7/week @ 2024-02-16 73/week @ 2024-02-23 123/week @ 2024-03-01 574/week @ 2024-03-08 1095/week @ 2024-03-15 1407/week @ 2024-03-22 1173/week @ 2024-03-29 1163/week @ 2024-04-05 984/week @ 2024-04-12 1066/week @ 2024-04-19 955/week @ 2024-04-26 1261/week @ 2024-05-03 1281/week @ 2024-05-10 1396/week @ 2024-05-17

5,051 downloads per month



vergen - A suite of libraries for generating cargo instructions from a Cargo build script

vergen, vergen-git2, vergen-gitcl, vergen-gix. vergen-pretty

When used in conjunction with cargo build scripts can emit the following output:

vergen-pretty is a macro and pretty printer for vergen based cargo instruction output.

Current Releases


docs.rs Crates.io Crates.io Crates.io codecov CI sponsor


docs.rs Crates.io Crates.io Crates.io


docs.rs Crates.io Crates.io Crates.io


docs.rs Crates.io Crates.io Crates.io


docs.rs Crates.io Crates.io Crates.io


The current minimum supported rust version is 1.70.0

⚠️ Notes on version 9 ⚠️

  • Version 9 introduces 3 new libraries, vergen-git2, vergen-gitcl, and vergen-gix that will be versioned independently from vergen.
  • The 3 new libraries are intended to be drop in replacements for vergen when you need to generate git based cargo build script instructions.
  • The git based features have been removed from the base vergen library.
  • vergen now contains the build, cargo, rustc, and sysinfo feature implementations. These features are re-exported by the new libraries allowing you to configure the output as you have previously.
  • Version 9 introduces the AddCustomEntries trait. Implementing this trait allows you to include your own custom Cargo instructions, using vergen as the engine to generate them. See the AddCustomEntries docs for more information.
  • The version 8 branch will be maintained for some time.


This was done to resolve issues with Cargo feature unification and mutually exclusive features. Previous versions of vergen had 3 mutually exclusive features (git2, gitcl, and gix). Feature unification could cause compilation issues if you had included a dependency that also used vergen but had configured a different git feature. Splitting the git backends into separate libraries helps alleviate this issue.

Migration from version 8

See the documentation at MIGRATING_v8_to_v9.md



See the documentation at CONTRIBUTING.md


Licensed under either of


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~650K SLoC