Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kamalmarhubi opened this issue Feb 14, 2017 · 7 comments · Fixed by #3857
Closed
Labels
C-bug Category: bug

Comments

@kamalmarhubi
Copy link
Contributor

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"
@alexcrichton
Copy link
Member

Definitely sounds like a bug!

@alexcrichton alexcrichton added the C-bug Category: bug label Feb 14, 2017
@alexcrichton
Copy link
Member

This should be a relatively easy bug to tackle by just throwing more fields into a hash I believe.

@kamalmarhubi
Copy link
Contributor Author

I'll give it a shot this week if nobody else gets to it.

@alexcrichton
Copy link
Member

Sure thing! Let me know if any help/guidance is needed

@antonlarin
Copy link
Contributor

It's been a while, can I try this one?

@alexcrichton
Copy link
Member

@antonlarin feel free! Lemme know if you need any help

antonlarin added a commit to antonlarin/cargo that referenced this issue Mar 23, 2017
Previously, when changing package properties with corresponding
environment variables (such as authors, which has CARGO_PKG_AUTHORS),
it didn't invalidate the build, even though there could have been
a dependency on such variables in the source code.

This commit includes such properties (there are 3 of them in total:
authors, description and homepage) in the target metadata.

Fixes rust-lang#3696.
bors added a commit that referenced this issue Mar 23, 2017
Include package props with corresponding env vars into target metadata

Previously, when changing package properties with corresponding environment variables (such as authors, which has CARGO_PKG_AUTHORS), it didn't invalidate the build, even though there could have been a dependency on such variables in the source code.

This commit includes 3 such properties: authors list, description and homepage in the target metadata.

I've added a test only for description change, can add more if necessary.
Fixes #3696.
@kamalmarhubi
Copy link
Contributor Author

Thanks @antonlarin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants