Skip to content

docs: clarify that package.include is independent from gitignore rules #16889

@unclepomedev

Description

@unclepomedev

Problem

The current documentation for the exclude and include fields explains that gitignore rules are applied when include is not specified, but does not explicitly state that gitignore rules are not applied when include is specified.

This leads to surprising behavior: a pattern like LICENSE in package.include will match files such as .venv/some-package/LICENSE, even if .venv/ is gitignored, causing cargo publish to fail unless --allow-dirty is passed.

context: #16872

Proposed Solution

Add a note to the exclude and include fields documentation clarifying that:

  • When include is specified, gitignore rules are not applied
  • Files in gitignored directories may still be matched unexpectedly
  • The ! prefix can be used to explicitly exclude such paths

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions