rust-lang / rust-lang/cargo

Possibility to set the package version dynamically

Open
#6,583 92 comments 109 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #14919 by @sunhaitao — closed without merging
A-manifest C-feature-request S-needs-rfc
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

View all comments

Maintainer notes


Hello

I'm building a rust application using internal teamcity CI job. I want the build number to be part of the version of the binary (so eg. ./app --version knows from which build it came).

The only way I found so far is to let the build first edit the Cargo.toml (sed -i -e 's/^version = .*/version = "%build.version%"/' Cargo.toml), which seems ugly and fragile.

It would be great if I could somehow override the version from Cargo.toml through the command line ‒ either as a parameter or an environment variable.

Would something like that make sense? Are there plans to support it?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue's dynamic-version design considerations and the linked pull request #14919, then review how Cargo currently handles the optional version field in Cargo.toml. Compare the proposed command-line and environment-variable approaches, and define the supported override behavior and its effect on package and binary versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.