Skip to content

cargo package does not obey .gitignore on crate in sub directories #6188

@Marwes

Description

@Marwes

Problem
Running cargo publish/cargo package on a crate in a sub-directory cargo errors because of uncommitted files despite the files being .gitignored. It does not matter if the file is gitignored at the top-level or in the crate's own directory.

Steps

  1. Create a directory structure as
.git/
.gitignore
crate/
    .gitignore
    Cargo.toml
    test.bak
    # etc

Where .gitignore contains

*.bak
**/*.bak

or any combination thereof

  1. Run (cd crate && cargo package)

Notes
Current workaround is to do git clean -fxd before releasing (which clears a bit to much).

cargo --version --verbose
cargo 1.31.0-nightly (5dbac9888 2018-10-08)
release: 1.31.0
commit-hash: 5dbac98885199bbd7c0f189d7405b5523434d1e3
commit-date: 2018-10-08

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions