Skip to content

Changes to Cargo.toml that result in a different environment should invalidate the build #3696

Closed
@kamalmarhubi

Description

@kamalmarhubi

Steps to reproduce:

  1. cargo build
  2. change a package field other than name or version that has an associated environment variable, eg description
  3. cargo build

Expected outcome: binary is rebuilt
Actual outcome: binary is not rebuilt

$ cargo version
cargo 0.16.0-nightly (6e0c18c 2017-01-27)
$ rustc -vV
rustc 1.15.1 (021bd294c 2017-02-08)
binary: rustc
commit-hash: 021bd294c039bd54aa5c4aa85bcdffb0d24bc892
commit-date: 2017-02-08
host: x86_64-unknown-linux-gnu
release: 1.15.1
LLVM version: 3.9

Transcript demonstrating the issue:

$ cargo new --bin bug
     Created binary (application) `bug` project
$ cd bug
$ cat src/main.rs 
fn main() {
    println!("Hello, world!");
}
$ sed -i 's/println.*/println!(r#"description = "{}""#, env!("CARGO_PKG_DESCRIPTION"));/' src/main.rs
$ cat src/main.rs 
fn main() {
    println!(r#"description = "{}""#env!("CARGO_PKG_DESCRIPTION"));
}
$ cargo build
   Compiling bug v0.1.0 (file:///tmp/bug)
    Finished debug [unoptimized + debuginfo] target(s) in 0.50 secs
$ target/debug/bug
description = ""
$ sed -i '/^name/a description = "some description"' Cargo.toml 
$ cargo build
    Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
$ target/debug/bug
description = ""
$ touch src/main.rs 
$ cargo build
   Compiling bug v0.1.0 (file:///tmp/bug)
    Finished debug [unoptimized + debuginfo] target(s) in 0.45 secs
$ target/debug/bug
description = "some description"

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions