Skip to content

cargo does not see Cargo.toml if .gitignore contains /* #14411

Closed
@cospectrum

Description

@cospectrum

Problem

If .gitignore is written in the style of "ignore everything except this", then cargo package --list for some reason does not see anything.
It seems to me that everything was fine on previous versions, I spent an hour investigating, did I miss something?

cargo version: 1.80.1 (376290515 2024-07-16)
git version 2.39.2 (Apple Git-143)
OS: mac

Cargo.toml:

[package]
name = "gitignore-bug"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "to reproduce bug"

[dependencies]

.gitignore:

/target
/*
!.gitignore
!Cargo.toml
!src

cargo package --list

warning: manifest has no documentation, homepage or repository.
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
warning: no `Cargo.toml` file found when packaging `gitignore-bug` (note the case of the file name).
.cargo_vcs_info.json
Cargo.lock

Steps

cargo init
echo '\n/*\n\n!.gitignore\n!Cargo.toml\n!src' >> .gitignore
git add . && git commit -m "."
cargo package --list

Possible Solution(s)

No response

Notes

cargo build is working, cargo publish is not working

Version

cargo 1.80.1 (376290515 2024-07-16)
release: 1.80.1
commit-hash: 37629051518c3df9ac2c1744589362a02ecafa99
commit-date: 2024-07-16
host: aarch64-apple-darwin
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.7.1 (sys:0.4.72+curl-8.6.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 13.6.8 [64-bit]

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