Skip to content

[package] include Cargo directive does not override .gitignore #4135

Closed
@pnkfelix

Description

@pnkfelix

I have a crate. It uses tango to keep a set of .md and .rs files in sync, but only the .md file is meant to be checked in, so the generated .rs are listed via a regexp in the .gitignore.

I was observing a problem: Edits to a generated .rs were failing to cause the crate's build script to be re-run, while edits to the .md were correctly causing the build script to be re-run. (The basic premise of tango is that touching either the .rs or .md file should cause the build script to be re-run.)

After some interactive debugging with @alexcrichton we determined that the issue appeared to be the fact that I had the generated .rs files listed in the .gitignore (as mentioned in the first sentence), as explained here: According to http://doc.crates.io/manifest.html#the-exclude-and-include-fields-optional :

If a VCS is being used for a package, the exclude field will be seeded with the VCS’ ignore settings (.gitignore for git for example).

So, okay: From what I can tell, that meant that updates to the .rs file was causing my build script to not run.

But also according to that same document:

setting include will override an exclude.

So apparently I should be able to list the files that my crate depends on explicitly in the include? Yet when I tried to do this by making a directive:

[package]
...
include = ["src/**/*.rs", "src/**/*.md", "tango-build.rs", "Cargo.toml"]

the crate nonetheless continued to fail to rebuild in response to modifications to the generated .rs files.


I have made a small branch to reproduce the problem without relying on subcrates like tango:

https://github.com/pnkfelix/mon-artist/tree/reduction-build-issue

The idea with this reduction of the bug is that this build script is a no-op, so you need to run cargo --verbose to observe the problem. The crucial issue is that after building the crate, doing the following should cause the build script to be re-run, but does not:

% touch src/lit/src/mod.rs
% cargo build --verbose
   Compiling reduction v0.1.1 (file:///Users/fklock/Dev/Rust/reduction)
     Running `rustc --crate-name mon_artist src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=f443131a805a9905 -C extra-filename=-f443131a805a9905 --out-dir /Users/fklock/Dev/Rust/reduction/target/debug/deps -L dependency=/Users/fklock/Dev/Rust/reduction/target/debug/deps`
    Finished dev [unoptimized + debuginfo] target(s) in 0.14 secs
%

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions